Pattern matching is the process of branching depending on provided patterns. All pattern matching is done within a switch expression, and individual case expressions represent the patterns.
The fundamental rules of pattern matching are:
_ pattern matches anything, so case _: is equal to default:.When all possible cases are handled, the catch-all _ pattern or default case is not required.