Null Safety
Types cannot hold null unless you add ?. Use ?. for safe calls, ?: for defaults and !! only when you are sure.
Example
var s: String? = null
println(s?.length)
println(s?.length ?: 0)
s = "hello"
println(s.length)Exercise
Elvis operator.
x 0
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.