Conditional Statements

suggest change

Remarks

In contrast to Java’s switch, the when statement has no fall-through behavior. This means that if a branch is matched, control returns after it runs, and no break statement is required. If you want to combine the behavior for multiple arguments, separate them with commas:

when (x) {
    "foo", "bar" -> println("either foo or bar")
    else -> println("didn't match anything")
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents