Wikia

WoWWiki

Talk:API select

102,281pages on
this wiki

Back to page

So I'm admittedly a Lua n00b, but does anybody know what the difference is between the

 MyAddon_Catenate(...) 

function on this page and

 { ... } 

? Or does {...} not work in WoW for some reason? Lazen (talk) 15:58, 21 April 2009 (UTC)

{...} -- table construct. Collects everything in the list and puts it into a table.
local function DoStuff(...)
    return {...}
end
local t = DoStuff("a", "b", 5)
for _, v in pairs(t) do
    print(v)
end
-- the above prints:
a
b
5
local function DoStuff(...)
    for i = 1, select("#", ...) do
        print((select(i, ...)))
    end
end
DoStuff("a", "b", 5)
-- the above prints:
a
b
5

The second is more efficient in that it doesn't make a new table whenever DoStuff() is called. Posted by: EGingell (T|C|F) on 07:16, 22 April 2009 (UTC)

Around Wikia's network

Random Wiki