February 2018
Intermediate to advanced
350 pages
7h 35m
English
Think of a situation where you need to declare a property at the class level, but you don't have the initial value for the variable there. You'll get the value at some later point, but before the property is actually used, and you're confident that the property will get initialised before using and it'll not be null. But, as per Kotlin syntax, you must initialize a property at the time of initializing. The quick fix is to declare it as a nullable var property, and assign a default null value. But as we mentioned earlier, since you are confident that the variable will not be null while using it, you are not willing to declare it as nullable.
Delegates.notNull is here to save you in this scenario. ...
Read now
Unlock full access