select(index, ···)
If index
is a number, returns all arguments after argument number index
. Otherwise, index
must be the string "#"
, and select
returns the total number of extra arguments it received.
Example
function sumargs(...)
local sum = 0
for i=1,select('#', ...) do
sum = sum + select(i, ...)
end
return sum
end