From: Robert Dober Date: 2008-04-08T08:47:41+09:00 Subject: Re: How to override a method defined in Ruby module On Mon, Apr 7, 2008 at 1:45 PM, Rick DeNatale wrote: > On Mon, Apr 7, 2008 at 7:33 AM, Sonar Volta wrote: > > > Is there module inheritance in Ruby? > > No, and yes. > > You can't do > > module A > end > > module B < A > end > > but you can do: > > module B > include A > end > > Which acts like a sort of inheritance. It does indeed look like that if you ask ruby itself, very much to my dispair :( (but that's why I have implemented traits) irb(main):001:0> a=Module::new => # irb(main):002:0> b=Module::new => # irb(main):003:0> b.send :include, a => # irb(main):005:0> b < a => true irb(main):006:0> c=Class::new => # irb(main):007:0> c.send :include, b => # irb(main):008:0> c.new.is_a? a => true I believe that this is misleading I might agree to c.new.behaves_like? a but if we go all the way to ducktyping even that is unacceptable. And yes you guessed correctly I am an inheritance skeptic but that is not because it is a bad feature (single inheritance) but it is not the right feature for code reuse, it is the right feature for modeling. Smalltalk which had no mixins suffered a lot from having to use SI for refactoring and code reuse, Squeak implemented traits for that very reason if I understood correctly. Cheers Robert > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > > -- http://ruby-smalltalk.blogspot.com/ --- Whereof one cannot speak, thereof one must be silent. Ludwig Wittgenstein