Chapter I · Language basics / Lesson 8 of 27

Varargs & multiple returns

You'll learn: Use ... to accept variable arguments and forward them with select.

A function declared with ... receives any number of extra arguments. select("#", ...) is the count; select(n, ...) is the tail starting at position n. Multiple return values flatten when they're the last expression in a call.

varargs.lua
Output idle
Hit Run to execute.
Try it: Add a min(...) function next to sum that returns the smallest argument. Use math.huge as the seed.