Kotlin 2 · Basics and null safety
Branch with when
when is a flexible switch that can be an expression.
val label = when (score) {
in 0..49 -> "low"
in 50..89 -> "ok"
else -> "high"
}
Official Kotlin 2 documentation
Kotlin 2 · Basics and null safety
when is a flexible switch that can be an expression.
val label = when (score) {
in 0..49 -> "low"
in 50..89 -> "ok"
else -> "high"
}
Official Kotlin 2 documentation
Was this page helpful?