Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Would you consider that an inconsistency if you weren't coming from the C paradigm of 0 == false?


Yes, because it's not just a C paradigm. Additionally, even though 1 is true, comparing 1 and true returns false!


1 is not the same value as true. Just as in the case I commented on a couple of messages above, 1 and true are two different types.

The == operator does not compare the "truthiness" of two values. It compares the values, and if those values are two different types, they are always unequal.

http://www.lua.org/pil/3.2.html


I'm aware of the reasons why. It's still inconsistent to users. Remember that Lua is targeted at non-professional programmers.


In my opinion, having (1==true) evaluated to true, but (2==true) evaluate to false is more inconsistent. Even non-professionals should follow logic if they are going to program.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: