by idea · 18y ago · 0 comments
If it's given two objects of different types, then it has to coerce one of them. In this case, I would expect it to coerce null to 0, then compare 0==0.
Your way would have it coerce 0 to false and null to false, so it's still equal, but it has to coerce two things.
I can sort of see the logic in this though, since a lot of other languages (SQL) have the rule that nothing is allowed to be equal to null.
Makes me wonder what the rules are for coercion though, that is does it pick null to coerce or 0?
null == 0 -> false?
It can't be because operands are converted to numbers or booleans, since 0 == 0 and false == false are both true.