(no title)
Ashanmaril | 4 years ago
== vs .equals() is pretty understandable considering that it's Java specific, and would be valid in most(?) other languages
Ashanmaril | 4 years ago
== vs .equals() is pretty understandable considering that it's Java specific, and would be valid in most(?) other languages
dave84|4 years ago
PennRobotics|4 years ago
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.
marcosdumay|4 years ago
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.
renox|4 years ago
And in VScode it isn't even possible to truly disable it!
chapium|4 years ago
The main reason I find myself second guessing this one is if you get used to the convention of other languages and then switch over to java.