How do I write an if
statement in Lua that negates (inverts/flips) a Boolean variable used as the condition?
For example, in Java, one can write:
boolean a;
a = false;
if (!a) {
//do something
}
I tried to replicate the above Java code in Lua using the following:
local a
a = false
if (~a) then
-- do something
end
However, I received an error. How do I write the Lua equivalent of the above Java snippet?
Lua uses mostly keywords. Use not a
instead of ~a
.