lua-users home
lua-l archive

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


Consider the following code:

local function a()
  return 1, 2, 3
end

local function b()
  return false or a()
end

print(b())

(end)

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.

Cheers,
V.