switch
Evaluates the discriminant once. break leaves the switch. No C fall-through; stacked cases share a body.
Syntax
Section titled “Syntax”switch (action) {case "buy":case "purchase": Grant(player); break;default: warn("unknown"); break;}Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
action | any | Compared with == to each case. |
Return value
Section titled “Return value”None.
Luau emit
Section titled “Luau emit”repeat … until true wrapping if / elseif
Description
Section titled “Description”Emitted as if / elseif / else inside repeat … until true so break still leaves the switch. Stacked cases share the body. default is the fallback.
Example
Section titled “Example”switch (action) {case "buy": Grant(player); break;default: warn("unknown"); break;}Emits:
-- discriminant evaluated once, then if/elseif inside repeat-until-true