The when Statement
Learn about when statement and enhance the code readability.
We'll cover the following...
We'll cover the following...
The when statement is an alternative to if-else-if. In every branch, we specify a predicate and the body that should be executed if this predicate returns true (and previous predicates did not). So, it works just like if-else-if but should be preferred because its syntax is better suited for multiple conditions.
Like in an if statement, braces are needed only for bodies with more ...