3 ms·
Correct me if I'm wrong, but what's inconsistent there is not boolean evaluation, it's number to boolean conversion. 1 == true and 0 == false are pretty standar
by Fargren 14y ago
Correct me if I'm wrong, but what's inconsistent there is not boolean evaluation, it's number to boolean conversion. 1 == true and 0 == false are pretty standard, but that doesn't mean 0 and 1 are booleans.
- vor_ 14y agoOnly nil and false evaluate to false. Because there's no distinction between nil and non-existent elements, checking the existence of an element with a value of 0 requires that 0 evaluates to true, so you get this situation: while 0 do print("loops forever") end while not 0 do print("does nothing") end
- spicyj 14y agoWhat you're saying is just that in Lua, 0 is truthy. Ruby is the same way, not a big deal.