Ary Borenszweig wrote:
Andrei Alexandrescu wrote:
Consider:

class Apple {}
class Orange {}

void main() {
    writeln(new Apple == new Orange);
}

This program always prints "false". By and large, it is odd that one would attempt comparison between unrelated classes. I was thinking, is this ever legitimate, or we should just disallow it statically whenever possible?

Has this brought problems to anyone ever?

I'm not sure about this particular aspect, but in Java the related method equals() has been a perennial source of issues. Just google for java equals.

Andrei

Reply via email to