lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I mean if you have no control over the function and you just want to
quickly build the returned values into an iteritable table?  Instead
of rewriting the function to return a table

On Sun, Jan 17, 2010 at 2:35 AM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> On Sun, Jan 17, 2010 at 12:29 PM, Majic <majic.one@gmail.com> wrote:
>> Hello, I've been trying to figure out the best way, or if there's a
>> shorthand way, to build a table from whatever is returned by a
>> function.
>
> http://batbytes.com/luafaq/#T1.23
>

local function whatever() return 1, 2, 3, 4, 5 end
local newtable = { whatever() }
print(unpack(newtable)) --> 1  2  3  4  5

Thanks! :)  Wish there were something hinting at that sort of
flexibility in the docs though...