From: Nick Bhanji Date: 2008-11-08T00:12:27+09:00 Subject: Re: array.equal? Nick Bhanji wrote: > Sebastian Hungerecker wrote: >> Nick Bhanji wrote: >>> My questions: >>> 1. why is equal? listed in the methods for the array >>> 2. what is the definition of equal? in the case of array? >>> 3. why is there another function eql? performing the actual equal test >> >> 1. Where exactly is it listed? It's not listed in the docs for Array. >> equal? is defined by Object and it is not overridden for any core class. >> 2. The same as for anything else: a.equal? b is true if and only if a >> and b >> are actually the same object (i.e. both a and b point to the same >> location in >> memory) > > you are correct to say that equal? is not in the Array docs. However, > when I executed > a = [1,1] > a.methods > > equal? method is there on the list of methods supported by the object > Array that is used by the variable a. > >> 3. eql? does not perform the "actual equal test" - whatever that is. >> eql? is >> to be used together with hash (and is indeed used that way by Hash, Set >> and > > "array.eql?(other) → true or false > Returns true if array and other are the same object, or are both arrays > with the same content. " --- from > http://ruby-doc.org/core/classes/Array.html > >> Array#&, Array#| and Array#-). >> 4. The method that I assume you're looking for is == >> >> HTH, >> Sebastian I did find the reference page that you probably used to explain. I got the reference that explains my imprise definition of equality that you were trying to explain. http://kentreis.wordpress.com/2007/02/08/identity-and-equality-in-ruby-and-smalltalk/ thank you everyone. Nick.B -- Posted via http://www.ruby-forum.com/.