|
|
|
|
|
by PennRobotics
1777 days ago
|
|
While == vs .equals() is a Java-specific issue, other languages suffer similar (and often more hidden) equality problems. In C, you can have value equality or pointer equality. Then, you have the whole "either write your own character-by-character comparison or learn which libraries to include to compare strings". There's also the detail of remembering what strcmp() returns. I might be wrong since Python is not my daily driver, but "a is b" and "a in b" and "a == b" and "a == b and type(a) == type(b)" are all distinct from one another. Javascript has strict equality and equality. |
|
That language feature is simply broken, and this is really not the same situation of confusing "a == b" with "a in b" or "type(a) == type(b)". One can say that comparison with None is Python is broken too, but the situation is much better because you get an error if you make a mistake, instead of your program misbehaving.
Javascript, by the way, is way worse than Java here. In general the language does not differentiate a number from a string with a numeric value (something I imagine it copied from Perl), yet a lot of features do.