WoW:API unpack: Difference between revisions

no edit summary
m (It's new)
 
No edit summary
Line 1: Line 1:
{{tocright}}
{{tocright}}
Returns the values in a table as a list
Returns the values in a consecutive-integer indexed table
  ret1, ret2, ... retN = unpack(table);
  ret1, ret2, ... retN = unpack(table)
 
Will not return values with hash style indexes.  For example:
local t = {1, "two", "3", x = "ecks", y = "why?"}
unpack(t) -- returns: 1, "two", "3"


== Arguments ==
== Arguments ==
Line 11: Line 15:


== Examples ==
== Examples ==
  local arg1, arg2, arg3 = unpack(
  local arg1, arg2, arg3 = unpack({1, 5, "Hearthstone"})
    {
        1,
        5,
        "Hearthstone"
    }
);
   
   
  -- This does the same thing:
  -- This does the same thing:
  local arg1, arg2, arg3 = 1, 5, "Hearthstone";
  local arg1, arg2, arg3 = 1, 5, "Hearthstone"
-- As does this:
local arg1 = 1;
local arg2 = 5;
local arg3 = "Hearthstone";


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