[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: multiple return value adjustment
- From: Viacheslav Usov <via.usov@...>
- Date: Wed, 14 Jun 2017 15:37:54 +0200
Consider the following code:
local function a()
return 1, 2, 3
local function b()
return false or a()
It prints just 1.
I think the manual specifies that behaviour in #3.4, sentence In all other contexts, Lua adjusts the result list to one element. No problem with that.
I have a little problem with the fact that the list of examples that follows has no example showing that multiple return values are adjusted to one when they are used with operators. It is easy to confuse "the last element of a list of expressions" (manual) with "the last sub-_expression_ in an _expression_" (the return statement in function b() above) and expect that somehow those multiple values will make it. I think a couple of examples with operators would be helpful.