The logical operators do not seem to interact as I expect
with argument adjustment:
Lua 3.1 (alpha) Copyright (C) 1994-1998 TeCGraf
> function foo() return 0, 1 end
> a, b = foo()
> a, b = nil or foo()
> a, b = 1 and foo()
I would have expected the second and third assignments to
have asigned 1 to b.
I came across this while trying to use calls to strfind
linked by or operators to find one of a series of patterns
in a string.
Dr Alan Watson
Instituto de Astronomía UNAM
> The logical operators do not seem to interact as I expect
> with argument adjustment:
Logical operators, like all operators, adjust their operands to 1 value before
performing any operation. In fact, the only places you can use a function call
and get all its returned values is in an assignment:
a,...,b = f()
or in a return statement:
Any other use of a function call will adjust its results.