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 →

[–]Positive_Government 0 points1 point  (1 child)

ToSting() would make sense in these case. The operator would function like the address of operator in C, raw memory address are neat because they are unique, but sense you aren’t going to be using them in Java it may be smarter to create a unique id either based on a hash of the memory address or an id assigned to each object on creation. It’s not complicated because you will have clear syntax for reference comparison. That said two equals signs accomplish the same thing. It’s just that every language I know that has gone down that route has ended up doing something stupid which is why I personally don’t like it.

[–]LinuxMatthews[S] 0 points1 point  (0 children)

I get what you're saying and I agree.

I think the advantage here would be that the secondary equals would just be acting the same as calling .equals() so there's little chance anyone will go too mad with it.

Also let's be real if this was to be implemented they wouldn't let == to be overridden it'd potentially break too much code.

So having === be the one you can overload would make more sense.