Android ● ○ ○ Kotlin 2.0

Kodebits Day 76: Elvis Operator

Aug 15 2026
Practice null-safety with a short kotlin challenge.

What is the output?

fun main() {
  val x: Int? = null
  val y = x ?: 10
  println(y * 2)
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

20

Explanation:

Elvis operator provides a default when the left side is null.

[/spoiler]


Further Reading