From: Robert Dober Date: 2007-01-25T00:21:01+09:00 Subject: Re: Trickery in the ancestors chain ------=_Part_7804_18857377.1169652059330 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/24/07, Paolo Nusco Perrotta wrote: > > Try this: > > module M > def hello; p 'M'; end > end > > class C > def hello; p 'C'; end > end > > class D < C; end > > class C; include M; end > class D; include M; end > D.ancestors -> [D, C, M, Object, Kernel] > D.new.hello -> "C" > > > Now restart from a clean slate and change the last few lines: > > class D; include M; end > class C; include M; end > D.ancestors -> [D, M, C, M, Object, Kernel] > D.new.hello -> "M" > > > Ruby silently prevents you from including a module that has been > included by an ancestor. Why? > > > Stop Press I can reproduce that behavior but only on my cygwin ruby 1.8.4 I cannot reproduce it in irb, irb seems to produce the correct behaviour (the first one for both versions). As soon as I'll have time I'll fire up tests on my Ubuntu with 1.8.5 and 1.9 . Robert -- "The best way to predict the future is to invent it." - Alan Kay ------=_Part_7804_18857377.1169652059330--