The classic switch statement is supported in many languages, including C, C++, and Java, but it is rather restrictive. At the same time, the functional programming concept of pattern matching has become more mainstream. Kotlin blends the two, and offers when, a more powerful alternative to switch while not going quite as far as full pattern matching.
There are two forms of when. The first is similar to switch, accepting an argument, with a series of conditions, each of which is checked, in turn, against the value. The second is without an argument and is used as a replacement for a series of if...else conditions.