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
Share this post