If judgment statement in lua language

The judgment of the lua language is rather mysterious, 0 is regarded as true

a=0
b=(a==0)
c=(a==1)
d=1
print(a)
print(b)
print(c)
if(b)
    then 
    print("a==0 means true")
    end
if(b==1)
      then 
    print("true means 1")
    else
    print("true do not mean 1")
    end
if(c==0)
    then
    print("false means 0")
    else
    print("c is false, but not means 0")
    end
if(c==1)
    then 
    print("false means 1")
    else
    print("c is flase, but not means 1")
    end
if(1)
    then 
    print("1 means true")
    end
if(0)
    then 
    print("0 means true")
    end

operation result

0
true
false
a==0 means true
true do not mean 1
c is false, but not means 0
c is flase, but not means 1
1 means true
0 means true

Guess you like

Origin blog.csdn.net/sinat_39416814/article/details/104560607