Boolean

boolean类型只有两个值:truefalse

print(type(true))       --> boolean
print(type(false))      --> boolean
print(type(nil))        --> nil

在做条件判断时,Lua把falsenil都看成是false

-- test.lua
if false or nil then
    print('at least one of them is false')
else
    print('both of them are false')
end

执行结果如下:

> lua test.lua
both of them are false

results matching ""

    No results matching ""