|
|
|
|
|
by randrews
6690 days ago
|
|
== needs two arguments of the same type. If they're both strings, it's a string compare. If they're objects, it does whatever it does for objects (identity, I think). If they're numbers, then it's a numeric comparison. 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?