From: Robert Dober Date: 2006-12-19T22:09:21+09:00 Subject: Re: compare two objects without take its ID in consideration ------=_Part_3678_31994315.1166533759282 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 12/19/06, Jeremy Wells wrote: > > Lobosque Lucas wrote: > > Is there a way to compare two objects without take its ID in > > consideration? For example: > > > > # == > > # > > > > It'll return false, because the object ID is different. But i want it to > > return true, because the arguments (is it the right name?) are all > > equal. > > > > Thanks > > > You can overwrite the == method: > > def ==(other_obj) > true if self.str == other_obj.str and self.mdfel == other_obj.mdfel > and self.name == other_obj.name > end > > Sorry for making some noise here, but before doing so please let me confirm that (1) the question was perfectly correct and normal (well I guess) (2) Jeremy's answer too. It just stroke me that maybe OP would have preferred not to post this question and having followed a link in a hypothetical FAQ ... Object Equality, what is ==, what keys are considered equal in a Hash, look here ==> http://www.ruby-doc.org/core/classes/Object.html#M000352 if that would not have helped her/him (I am abstracting from your post Lucas) I guess any question posted would have been answered too. Are there some folks kind of imagining the usefulness of such a collection to be posted regularly, it might be tagged clearly e.g. [RUBY-FAQ-L0] and be filtered out by your mail client if you are not interested. If the FAQ is really good it might make it to the ruby site ;) Cheers Robert -- "The real romance is out ahead and yet to come. The computer revolution hasn't started yet. Don't be misled by the enormous flow of money into bad defacto standards for unsophisticated buyers using poor adaptations of incomplete ideas." - Alan Kay ------=_Part_3678_31994315.1166533759282--