WoW:API unpack: Difference between revisions

218 bytes added ,  17 September 2009
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
{{tocright}}
{{tocright}}
Returns the values in a consecutive-integer indexed table
Returns the values in a consecutive-integer indexed table
  ret1, ret2, ... retN = unpack(table)
  ret1, ret2, ... retN = unpack(table[, start][, end])


Will not return values with hash style indexes.  For example:
Will not return values with hash style indexes.  For example:
Line 10: Line 10:
=== Parameters ===
=== Parameters ===
:;table: (table) - A table
:;table: (table) - A table
:;start: Integer - Starting index, defaults to 1 if nil
:;end: Integer - Ending index, appends nil values if the table does not contain enough


=== Returns ===
=== Returns ===
Line 19: Line 21:
  -- This does the same thing:
  -- This does the same thing:
  local arg1, arg2, arg3 = 1, 5, "Hearthstone"
  local arg1, arg2, arg3 = 1, 5, "Hearthstone"
unpack({1,2,3,4,5},2,7)  -- returns 2, 3, 4, 5, nil, nil


{{LUA}}
{{LUA}}
Anonymous user