Equal? vs eql? vs ==

I’m working on writing a set of classes that implement weak versions of Hash,
Array, and other classes that make sense. In doing so, I see there are four
different methods that provide equality.

Object#eql?
Object#===
Object#==
Object#equal?

I understand why #eql? and #=== are separate from the others, but I don’t quite
understand why there are both #== and #equal? are they testing for different
kinds of equality?

Thanks,
Samuel

ri is you friend :wink:

 obj.equal?( anObject ) -> true or false
···

il Fri, 26 Dec 2003 20:44:08 -0600, Samuel Tesla samuel@alieniloquent.com ha scritto::

I understand why #eql? and #=== are separate from the others, but I don’t quite
understand why there are both #== and #equal? are they testing for different
kinds of equality?


 Returns true if obj and anObject have the same object ID. This
 method should not be overridden by subclasses.

 obj == anObject -> true or false

 Equality---At the Object level, == returns true only if obj and
 anObject are the same object. Typically, this method is  
 overridden in descendent classes to provide class-specific
 meaning.

gabriele renzi surrender_it@remove.yahoo.it writes:

 obj.equal?( anObject ) -> true or false

 Returns true if obj and anObject have the same object ID. This
 method should not be overridden by subclasses.

You know, I read that. For some reason I did not register the word “not” in
the second sentence.

Thanks.

– Samuel