From: Joel VanderWerf Date: 2003-10-02T04:03:29+09:00 Subject: Re: Making == symmetric? Zach Dennis wrote: ... > on #1. I agree with Mark and I'd also like to say...why would you want > to use the == to return true when comparing different objects, even if > they are of the same class, with the same attributes. Unless one's a pointer > or reference and you are using an equivalency of a === test. I don't see why > someone would want this expected behavior from == itself. Well, for example: irb(main):001:0> [1,2] == [1,2] => true Also, strings. Of course, this isn't really a "class with attributes", but even for user defined classes, I sometimes define #== to work this way. This seems like the right thing to do for geometrical objects, like points. YMMV. > > on #2. I think 2 different classes should always return false when compared > to > one another. Otherwise you are getting away from the simplicity and purpose > of a comparison in it's most generic form and you are bringing > in special cases where "behavior is varied". If you want to allow for > special case scenario's then perhaps make a new comparison operator/method > and leave == alone. irb(main):002:0> 1.0 == 1 => true Or, if you had two Point classes, one maintaining its state in polar coordinates, and the other in cartesian coordinates, you might want equality to transcend class boundaries.