From: Andrea Date: 2005-12-20T00:36:52+09:00 Subject: Re: TheYAML change the id of Object Logan Capaldo wrote: > On Dec 19, 2005, at 9:10 AM, Andrea wrote: > >> @descrizione = descrizione >> >> #:Key T3 in lingua it -- Value: Definizione tre >> > You need to overload the == operator and the hash method. > > class Termine > alias eql? == > def ==(other) > descrizione == other.descrizione and lingua == other. lingua > end > def hash > (descrizione + lingua).hash > end > end > > t = Termine.new("Hi") > t2 = Termine.new("Hi") > > t == t2 #=> true > > h = {} > h[t] = "short hello" > h #=> {#=>"short > hello"} > h.has_key?(t2) #=> true Thank for your help... this is that I need... --Andrea -- Posted via http://www.ruby-forum.com/.