BeginnerNull Safety
Safe Call Operator
Access properties of nullable values safely.
kotlin
fun main() {
val name: String? = null
println(name?.length)
}Output
null
Explanation
?. is the safe call operator. If name is null, the result is null instead of throwing NullPointerException.