lua-users home
lua-l archive

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


ddneilson wrote:
table1 = { "A", "B" }
table2 = { "C", "D" }
print(unpack(table1))
print(unpack(table1), unpack(table2))

Expected output:
A B
A B C D

Actually, you should *not* expect the above. See http://www.lua.org/manual/5.1/manual.html#2.5.

Actual output:
A B
A C D


This holds for all functions, not just unpack. If the function invocation appears anywhere in the list of arguments to a function, except the last position, its list of return values is adjusted to return just the first value.

If it wasn't midnight, I could probably explain this more clearly.


Matt