Destructuring
-
Destructuring is done primarily through the
let
andmatch
statements -
A
let
pulls the variables out into the current scope, whereasmatch
introduces a new scope
fn foo(pair: (int, int)) { let (x, y) = pair; // we can now use x and y anywhere in foo match pair { (x, y) => { // x and y can only be used in this scope } } }