lua-users home
lua-l archive

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


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()
    > print(a)
    0	
    > print(b)
    1	

    > a, b = nil or foo()
    > print(a)
    0	
    > print(b)
    nil	

    > a, b = 1 and foo()
    > print(a)
    0	
    > print(b)
    nil	

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.

Alan
-- 
Dr Alan Watson
Instituto de Astronomía UNAM