Safely handle nullable values using the safe call operator (?.
) and provide a default value using the Elvis operator (?:
).
val text: String? = null
val length = text?.length ?: 0
Safely handle nullable values using the safe call operator (?.) and provide a default value using the Elvis operator (?:).
Safely handle nullable values using the safe call operator (?.
) and provide a default value using the Elvis operator (?:
).
val text: String? = null
val length = text?.length ?: 0