WoW:API unpack: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
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}}

Revision as of 08:44, 18 July 2007

Returns the values in a consecutive-integer indexed 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

Parameters

table
(table) - A table

Returns

ret1, ret2, ... retN
A list of the values contained in the given table.

Examples

local arg1, arg2, arg3 = unpack({1, 5, "Hearthstone"})

-- This does the same thing:
local arg1, arg2, arg3 = 1, 5, "Hearthstone"

Template:LUA