Introduction
The when expression in Kotlin lets you choose a value based on conditions. It returns a result, so you can use it directly where a value is needed.
Choosing a message to show based on a user's age
Setting a color based on a traffic light signal
Returning a discount percentage based on customer type
Picking an action based on a button clicked