[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Expanding multiple return values of Lua functions in a Lua table constructor
- From: agentzh <agentzh@...>
- Date: Wed, 17 Oct 2012 12:28:25 -0700
Hello, folks!
Sorry if this is a FAQ. I'm stumbling on the following example with
Lua 5.1.4 and 5.1.5:
$ lua -e 'function foo(a) return a, "d" end local tb = {
foo("ab"), foo("c") } print(table.concat(tb))'
abcd
Why is the output neither "abdcd" nor "abc"? Why is the second return
value of the first foo() call swallowed by the table constructor while
the second foo() call is not?
LuaJIT 2.0.0 beta11 is giving exactly the same result.
I'm afraid the current behaviour is quite unintuitive. Opinions?
Thanks!
-agentzh