Earlier, we introduced several ways to use blocks for lexical scope and control flow. Now that we can build more complex values using aggregate data types, it is time to introduce additional block-based statements that are very convenient for handling complex values:
- this blocks. Enables some block to focus its work on a particular value.
- each blocks. Enables some block to iterate over collection of values, including the elements of a collection.
- pattern matching. Chooses the logic to evaluate based on the structure or values that lie within some aggregate value.