// because the other answers didn't show it, you can also do: val boolA = .... val boolB = .... when { boolA -> { // stuff } boolB -> { // stuff } } // for an example, here's something from a libGDX project of mine: when { Gdx.input.isKeyPressed(Input.Keys.W) -> y += getSpeed(diag) Gdx.input.isKeyPressed(Input.Keys.S) -> y -= getSpeed(diag) }val x = 3 when(x) { 3 -> println("yes") 8 -> println("no") else -> println("maybe") } // when can also be used as an expression! val y = when(x) { 3 -> "yes" 8 -> "no" else -> "maybe" } println(y) // "yes"fun numberTypeName(x: Number) = when(x) { 0 -> "Zero" // Equality check in 1..4 -> "Four or less" // Range check 5, 6, 7 -> "Five to seven" // Multiple values is Byte -> "Byte" // Type check else -> "Some number" }fun signAsString(x: Int)= when { x < 0 -> "Negative" x == 0 -> "Zero" else -> "Positive" }// Basic usage of the when statement in Kotlin fun main() { val number = 1 when (number) { 1 -> println("One") 2 -> println("Two") 3 -> println("Three") else -> println("Other") } }