Pattern matching cho phép khớp giá trị và destructure cùng lúc.
Ví dụ với switch: switch (shape) { case Circle(radius: var r) => print('Circle r=$r'); case Rectangle(width: var w, height: var h) => print('Rect ${w}x${h}'); }.
Patterns match values and destructure them simultaneously.
Example: switch (shape) { case Circle(radius: var r) => print(r); case Rectangle(width: var w, height: var h) => print('${w}x${h}'); }. Guard clauses add conditions: case (int a, int b) when a > b. Patterns also work in variable declarations: var (x, y) = getPoint();. Far more declarative than if/else chains.