lua-users home
lua-l archive

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


>From §2.5.7 of the Lua 5.1 reference manual, which is about table constructors:
"If the last field in the list has the form exp and the expression is
a function call or a vararg expression, then all values returned by
this expression enter the list consecutively (see §2.5.8)."

The message to take away from this is that things are truncated to
exactly 1 result iff they are not the last thing in an expression
list.

On Sat, Oct 1, 2011 at 6:25 PM, Thijs Koerselman
<thijskoerselman@gmail.com> wrote:
> I feel really stupid for asking this.
> local pos = {unpack({1,2,3}), 4}
> print("pos size ".. #pos)
> I would expect #pos to return 4, but instead its 2. A more real world
> situation would be to convert a vec3 to vec4 like this:
>         local vec4 = {unpack(vec3), 1}
> What the heck am I missing?
> Thijs