Pattern Matching

Pattern matching provides a concise, convenient way to bind parts of large objects to new local variables. Two Cyclone constructs use pattern matching: let declarations and switch statements. Although switch statements are more common, we suggest starting with Let Declarations because they have fewer complications. Then review all the Pattern Forms before considering Switch Statements.

Note that you must use patterns to access values carried by Tagged Unions, including exceptions. In other situations, patterns are optional, but make code more readable and less verbose.

Matching against unique pointers is explained in Pattern Matching on Unique Pointers.