local
Updatedlocal x: T = expr local { name, hp = health } = player local [first, ...rest] = xs local Build(model) = job local Ok(v) = result else return end
Luau's binding, with three forms of its own. A table pattern takes fields by name, = alias renames one, name: T gives one its type, and ...rest takes the fields it leaves as a table. An array pattern takes items by position, and ...rest takes the tail as an array. A variant or struct pattern binds its payload: local Build(model) = job reads the payload of one variant, and a value of another variant raises, naming the pattern and the tag it found. With else ... end the block runs instead, and it must leave, with return, break, continue, or an error, so the names hold after it. An else that can reach its end is a compile error. const takes every form too.
A parameter takes the table pattern too: function draw({ x, y }: Point) binds the fields of its argument on the header's line. The annotation names the type, or the typed fields state it, function foo({ bar: string, baz: number }). A pattern with no type is an error, and so is one that states it twice. A method, a trait signature, a function expression, a macro, and a declare take one; a remote does not, since the wire reads each parameter by its name. A name the signature binds twice is an error.
