[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Passing table as vararg ( newbie question )
- From: Shaun McVey <shaun.mcvey@...>
- Date: Sat, 19 Sep 2009 18:03:52 +0100
How about changing:
local x,y = table1
to local x,y = unpack(table1)
When you do local x, y = table1, all you're doing is assigning x the
first expression on the right side of the assignment (the table) and y
to nil.
On Sat, Sep 19, 2009 at 6:00 PM, Colm Sloan <colmsloan@gmail.com> wrote:
> 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?