Lua 4.0 undeclared variables and conditional statements

This bit of code confuses me.

print(gogo) if (gogo == true) then print("yes") elseif (gogo == false) then print("no") end 

Why is gogo evaluating to true ? Should it not appear an error?

+4
source share
1 answer

It does not evaluate to true and cannot, because in Lua 4.0 there is no boolean type.

 print(true) -- prints "nil" 

Undefined global nil variables by default, so really gogo == true . They are both nil .

+6
source

Source: https://habr.com/ru/post/1500694/


All Articles