Fandom

WoWWiki

Talk:API select

Back to page

104,635pages on
this wiki
Add New Page

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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)

Also on Fandom

Random Wiki