WoW:API select: Difference between revisions

m
no edit summary
({{luaapi}})
mNo edit summary
Line 1: Line 1:
{{luaapi}}
{{wowlua}}
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).
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 5: Line 5:
== Arguments ==
== Arguments ==
=== Parameters ===
=== Parameters ===
:;index : Any non-zero number or the string "#".
:;index
:;list : Usually an ellipsis (...).
:: Any non-zero number or the string "#".
:;list
:: Usually an ellipsis (...).


=== Returns ===
=== Returns ===
:;retN : The number of items in the list or every value starting from index to the end of the list.
:;retN
:: The number of items in the list or every value starting from index to the end of the list.


== Examples ==
== Examples ==
Line 29: Line 32:


=== Catenation ===
=== Catenation ===
select can be used to catenate a vararg list into an array. This is useful for returning info from [[API_GetBinding | GetBinding]], which returns a vararg list of unknown size.
select can be used to catenate a vararg list into an array. This is useful for returning info from [[API_GetBinding | GetBinding]], which returns a vararg list of unknown size.


  function MyAddon_Catenate(...)
  function MyAddon_Catenate(...)