Conditional Statements
suggest changeRemarks
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")
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents