An expression is considered false, for the purposes of any condition statement, on exactly two conditions: the expression is the boolean value false or the expression is nil.
So if x then foo() end will call foo if x is neither nil nor false. If you want to restrict it to nil only (and you usually don't), then use x ~= nil.
An expression is considered false, for the purposes of any condition statement, on exactly two conditions: the expression is the boolean value
falseor the expression isnil.So
if x then foo() endwill callfooifxis neithernilnorfalse. If you want to restrict it tonilonly (and you usually don't), then usex ~= nil.