What is the difference between: ```class SomeCla...
# announcements
i
What is the difference between:
Copy code
class SomeClass1(private val property: Application)
and
Copy code
class SomeClass2() {

   private val property: Application? = null
}
I've noticed that in the second example of property declaration you HAVE to initialize property otherwise the compiler says that property needs to be abstract or initialized, but on the other hand in the first example initialization is optional.
d
The first one also declares a constructor with a parameter called
property
and initializes the property
property
with that parameter's value. The 2nd one declares a no-argument constructor
j
It's not optional in the first example. It's exposed as a constructor parameter whose value is assigned to the property.
e
if SomeClass1 has constructor(private val property: Application? = null), there's no differences Assignment null to property (especially val), it will be influenced Nothing? since it is bottom type So calling SomeClass2#property#someAppMethod is okay but never successful.