why kotlin has to assign a field var a default val...
# getting-started
x
why kotlin has to assign a field var a default value?it says "Property must be initialized or be abstract“
b
xxxifan: Because all Kotlin types are not null by default and therefore must be initialized with a not null value. (So no more NotNullPointer exceptions!) If you want to have a nullable declaration, you can do this by adding a question mark to mark it as optional: e.g. Integer?
x
but the question is still here even if I set this variable as nullable
j
Since it's not null by default you have to explicitly set nullable types to null
v
because fun can live by itself