[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Passing table as vararg ( newbie question )
- From: "GrayFace" <sergroj@...>
- Date: Sun, 20 Sep 2009 00:07:41 +0700
Use call
Foo (var1, unpack({var2, "var3"}))
or use
function Foo( firstvar, tablevar)
local v1, v2 = tablevar[1], tablevar[2]
----- Original Message -----
From: Colm Sloan
To: Lua list
Sent: Sunday, September 20, 2009 12:00 AM
Subject: Passing table as vararg ( newbie question )
I just want to get access to var2 and var3.
Foo ( var1,
{ var2, "var3" }
)
function Foo( firstvar, ... )
local v1, v2 = ... -- says that v1 (var2) is a table :(
-- test to see how deep this table goes
-- causes infinite loop
local table1 = ...
while ( type( table1 ) == "table" ) do
local x, y = table1
table1 = x
print( "\nanother table" )
end
end
What's going on here? Why can't I access var2 and var3? I'm sure I'm making
some simple mistake. I tried {{table1}} but that made no difference. Any
ideas?