Kotlin - Null Safety
What will be the output of this Kotlin code?
fun main() {
val text: String? = null
println(text?.length ?: "No text")
}fun main() {
val text: String? = null
println(text?.length ?: "No text")
}text?.length safely accesses length only if text is not null.text is null, text?.length is null, so the Elvis operator ?: returns "No text".15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions