A lot of the examples of switch expressions you can find are where a function directly maps to an expression. For example:
This could make you think that you cannot use a switch expression inside a method body. It certainly is possible. The only important thing is that you assign the result of your switch expression to a variable. Let’s rewrite the example above: