no edit summary
m (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...) |
No edit summary |
||
| Line 1: | Line 1: | ||
{{tocright}} | {{tocright}} | ||
Used to traverse a list. This function is usually used to capture the arguments passed to an | Used to traverse a list. This function is usually used to capture the arguments passed to an ellipsis (...). The official usage of this function is to return a list (retN) starting from index to the end of the list (list). | ||
local ret1, ret2, retN = select(index, list) | local ret1, ret2, retN = select(index, list) | ||
| Line 6: | Line 6: | ||
=== Parameters === | === Parameters === | ||
:;index : Any non-zero number or the string "#". | :;index : Any non-zero number or the string "#". | ||
:;list : Usually an | :;list : Usually an ellipsis (...). | ||
=== Returns === | === Returns === | ||
| Line 13: | Line 13: | ||
== Examples == | == Examples == | ||
-- Common usage. | -- Common usage. | ||
local num = select('#', ...) -- Returns the number of arguments in the | local num = select('#', ...) -- Returns the number of arguments in the ellipsis. | ||
local arg = select(i, ...) -- Returns the value at index '''i'''. | local arg = select(i, ...) -- Returns the value at index '''i'''. | ||
-- Print all of the function's arguments (those passed to the | -- Print all of the function's arguments (those passed to the ellipsis (...) only) to the default chat frame. | ||
for i = 1, select('#', ...) do | for i = 1, select('#', ...) do | ||
DEFAULT_CHAT_FRAME:AddMessage(select(i, ...)) | DEFAULT_CHAT_FRAME:AddMessage(select(i, ...)) | ||