[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: newbie to lua :-) a trivial question...
- From: Pierre-Yves Gérardy <pygy79@...>
- Date: Thu, 18 Nov 2010 13:11:28 +0100
On Thu, Nov 18, 2010 at 12:14, starwing <weasley.wx@gmail.com> wrote:
>
> hi all...
> I'm confused about the multi return value of Lua.
> how can I insert the multi return value from a function to a middle of a table?
You can do it to some extent in a table constructor literal:
a=function() return 1,2,3 end
b={5,6,a()} --> b is now {5,6,1,2,3}
However, if the returned values are not inserted at the end of the
table, only the first returned value will be assigned.
c={5,6,a(),9} --> c is now {5,6,1,9}
The same rules apply to varargs:
z=function(...) return {55,...} end
z(1,2,3) --> { 55, 1, 2, 3 }
but
w=function(...) return {...,18} end
w(1,2,3) --> { 1, 18 }
Regards,
-- Pierre-Yves