From: Robert Dober Date: 2006-08-18T15:46:52+09:00 Subject: Re: How to - Change operator behaviour ------=_Part_825_23503572.1155883610356 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 8/17/06, Simen Edvardsen wrote: > > On 8/17/06, Henry Savr wrote: > > It's new behaviour should be like this: > > > > class Time1 < Time > > def >(other) > > case other.class.name > > when "Time" > > return self > other # but use the OLD > method > definition. > > when ("NilClass") > > return true > > else > > # do what Ruby does originally in this case : when one > operand is > > Time, and other not the Time. > > end > > end > > Unrelated hat tip: many classes define the #=3D=3D=3D method, for "case > equality", and it's used in case statements. Your code could be > simplified to case object1 when object2 triggers object2's =3D=3D=3D method with object1 as its sole parameter... case other > when Time > self > other Just to see "How deep is your Stack?" > when NilClass > true > end ...therefore Time's =3D=3D=3D method is triggered which is defined in Clas= s. Unless one un/redefines the "=3D=3D=3D" method from a Class objetc (e.g. class << String undefine_method :=3D=3D=3D ; end ) one can always rel= y on =3D=3D=3D from classes to check for instance Cheers Robert --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_825_23503572.1155883610356--