Introduction
Switch expressions with patterns let you choose a result based on the shape or value of data in a clear and simple way.
You want to return different results based on the type of an object.
You need to check if a value fits certain conditions and respond accordingly.
You want to replace long if-else chains with cleaner code.
You want to match values and extract parts of data easily.