From: Mathieu Bouchard Date: 2001-02-26T18:18:08+09:00 Subject: [ruby-talk:11578] Re: Time without seconds (updated/fixed) On Mon, 26 Feb 2001, Yukihiro Matsumoto wrote: > In message "[ruby-talk:11459] Re: Time without seconds (updated/fixed)" > on 01/02/25, ts writes: > |Y> class B |Y> a = A[1] + B[2] > |Y> What do you expect? A? B? Array? > Hmm, pretty complecated rules... Let me think. It seemed to me that Guy expects the class of the result to be the "smallest" class c for which c >= self.type and c >= other.type ... this is usually called a maximum (when used with numbers). So this is why I call it "max" in the following example (even though the result may be a third class... hmmm; maybe should name it: deepest_common_superclass instead). class Class def superclass_list a=[c=self] while c!=Object; c=c.superclass; a<0 and a1[-1]==a2[-1] c = a1.pop; a2.pop end c end end Note that this definition of array return type conflicts with MetaRuby, where Array emulators are not subclasses of Array... thus Array#+ would return a plain Object (!). matju