API select

From Wowpedia
Revision as of 09:59, 14 January 2008 by Egingell (talk | contribs) (New page: {{tocright}} Used to traverse a list. This function usually used to capture the arguments passed to an ellipse (...). local num = select('#', ...) -- Returns the number of arguments in th...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Used to traverse a list. This function usually used to capture the arguments passed to an ellipse (...).

local num = select('#', ...) -- Returns the number of arguments in the ellipse.
local arg = select(i, ...) -- Returns the value at index i.

Arguments

Parameters

Number or '#'
list - Usually "..."

Returns

Number of list items or the value at the given index.

Examples

-- Print all of the function's arguments (those passed to the ellipse only) to the default chat frame.
for i = 1, select('#', ...) do
    DEFAULT_CHAT_FRAME:AddMessage(select(i, ...))
end

Template:LUA