Object equivalence

i have two objects, a and b, both of the same class.
i believe they have the same contents, but
a.eql?(b) returns false

if i write a method xxx that returns as a string the value of every
field
(much as to_s does), then a.xxx.hash == b.xxx.hash.
i believe this latter shows a and b are equivalent; o why
doesn’t eql? agree?

On 7/24/07, Andrew H. [email protected] wrote:

i have two objects, a and b, both of the same class.
i believe they have the same contents, but
a.eql?(b) returns false

if i write a method xxx that returns as a string the value of every
field
(much as to_s does), then a.xxx.hash == b.xxx.hash.
i believe this latter shows a and b are equivalent; o why
doesn’t eql? agree?

eql? is just a method and therefore depends on the implementing
object. By default, eql? returns true only if the objects being
compared are the same object. And then, each class typically
overrides eql? to do as the developer sees fit.

Todd