Explore Library
KotlinIntroduction & Core Concepts

50 items

Code QuizBeginner

when as an expression

Understand exhaustiveness requirements for a when expression.

Codekotlin
fun main() {
    val x = 3
    val result = when (x) {
        1 -> "one"
        2 -> "two"
    }
    println(result)
}

What is the bug in this code?