February 2018
Intermediate to advanced
350 pages
7h 35m
English
Instead of a null value, the !! operator will throw an NPE:
val result: String = nullableCupcake!!.eat()
If you can deal with an NPE, the !! operator gives you a pretty convenient feature, a free smart cast:
val result: String = nullableCupcake!!.eat()val length: Int = nullableCupcake.eat().length
If nullableCupcake!!.eat() doesn't throw an NPE, Kotlin will change its type from Cupcake? to Cupcake from the next line and onwards.
Read now
Unlock full access