How to work with kotlin's `when` expression?

The `when` expression in Kotlin replaces the switch operator in other languages and can be used both as an expression and as a statement. Here's how it functions:


  val number = 3
  when (number) {
      1 -> println("One")
      2 -> println("Two")
      3 -> println("Three")
  }
  

Beginner's Guide to Kotlin