As shown in the diagram above, it is quite possible that two different objects can represent the same real world thing, and the same object can, at different times, represent different things. Since "==" simply says that two different references to objects point to the same object, it has little to do with the references pointing to the same "thing".
Monday, May 14, 2007
== considered harmful
Once one realizes that objects aren't entities, and that they very often are representations of real world things, one realizes that the "==" (equals) operator is dangerous!
Labels:
equals,
identity,
programming,
types
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment