Handling Nullable Values

Safely handle nullable values using the safe call operator (?.) and provide a default value using the Elvis operator (?:).

Handling Nullable Values
Photo by Marc Reichelt / Unsplash

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