Syntax
select("#", ...); select(index, ...)Examples
Lua select and argument counts
Run with standalone Lua 5.4: lua example.lua. These scripts target Lua 5.4 rather than Roblox Luau.
local function inspect(...)
print(select("#", ...))
for i = 1, select("#", ...) do
local value = select(i, ...)
print(i, tostring(value))
end
end
inspect("Ada", nil, false)- Output starts with 3, then pairs 1/Ada, 2/nil, 3/false. Assigning select to one local keeps only the first value of its suffix.
Best practices
- select(index, ...) can return multiple values as a final argument. Capture a single local when only one value is intended.
Runtime & versions
Lua interpreter or a host application. Feature availability depends on the language and runtime version used by your project; consult the official reference below.
Lua reference manuals