February 2018
Intermediate to advanced
350 pages
7h 35m
English
Check for null as a condition in the if block:
fun main(args: Array<String>) { val nullableCupcake: Cupcake? = Cupcake.almond() if (nullableCupcake != null) { nullableCupcake.eat() }}
Kotlin will do a smart cast. Inside the if block, nullableCupcake is a Cupcake, not a Cupcake?; so, any method or property can be accessed.
Read now
Unlock full access