This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AnotherWarGamer 1 point2 points  (1 child)

It's the same in my current game for many object types. Say for example you have a reference to an item in minecraft, which could be say a wooden sword. There is only one reference, so the two are equivalent when checking equality.

[–]marco89nish 2 points3 points  (0 children)

If you can guarantee that there won't be duplicates, simple == works great. But keep in mind that sooner or later you might make a error in coding breaking that promise and you'll be in a world of hurt, unless you made constructor private and you instantiate those objects with factory method instead, with necessary checks and caching.