Kotlin: using the when expression

Example:

val x = 5
The "when" expression replaces the switch statement in Kotlin.

Solution:

when (x) { 1 -> print("x == 1") 5 -> print("x == 5") else -> print("x is neither 1 nor 5") }

Beginner's Guide to Kotlin