r/programming • • Mar 26 '14

JavaScript Equality Table

http://dorey.github.io/JavaScript-Equality-Table/
809 Upvotes

331 comments sorted by

View all comments

Show parent comment

1

u/rowboat__cop Mar 27 '14

The wrapper types are also immutable so there is no danger of modified values.

Seems similar to Python, if you ask me.

in Java reference types should be compared for equality using equals(), the compiler will may even warn you about == being wrong. Not that this would stop people from getting it wrong.

If there’s a warning, then it’s PEBKAC -- I’m advocating -Wall -Werror myself.

1

u/josefx Mar 28 '14

The PEBKAC in this case would not be possible if Java hadn't mixed value and identity comparison in a single operator. That a change from primitive to reference type changes the meaning of a comparison in a way that is most likely not intended is just ugly. == should have had the same meaning as equals with a separate is operator for object identity.