Hi!
I have not seen any reason why are the following print commands makes different output:
a={1,2,3,4,5}
nprint(unpack(a),"*") -> result: 1 *
while
nprint("*",unpack(a)) -> result: * 1 2 3 4 5
???
Unpack() with others in a print()
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Unpack() with others in a print()
That's the way Lua adjusts function return values. From the Lua book:
See here: http://www.lua.org/pil/5.1.htmlLua always adjusts the number of results from a function to the circumstances of the call. When we call a function as a statement, Lua discards all of its results. When we use a call as an expression, Lua keeps only the first result. We get all results only when the call is the last (or the only) expression in a list of expressions.