Kotlin - Operators and Expressions
What is the output of the following Kotlin code?
val a: String? = null val b: String? = "Hello" val c: String? = null val result = a ?: b ?: c ?: "Default" println(result)
What is the output of the following Kotlin code?
val a: String? = null val b: String? = "Hello" val c: String? = null val result = a ?: b ?: c ?: "Default" println(result)
a is null, so Elvis operator moves to b. b is "Hello", which is not null.b is not null, result is assigned "Hello" and the rest is ignored.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions