Tsallaka zuwa abun ciki
Justice Tech School

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

What does String? allow?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.