Chapter I ·
Language basics
/
Lesson 7 of 27
First-class functions
You'll learn: Pass and return functions, capture multiple returns, and discard with
_.
Functions are values: pass them, return them, store them in
tables. Multiple return values are first-class. Assigning fewer
names drops extras (local q = divmod(17, 5)). Use _ as a
discard. Only the *last* call in an expression list flattens —
wrap in parens to truncate to one.
Output
idle
Hit Run to execute.
Try it:
Wrap the last call as
(divmod(100, 7)). The remainder vanishes from the return — the extra parens force single-value context.