From: James Coglan Date: 2009-02-17T00:43:11+09:00 Subject: Re: Inherit and override in the same time? --000e0cd248fa08e2da04630b0906 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit > > I ended up doing this, which apprently works. > > ---------------------------- > class Parent > def go > puts 'parent' > end > end > > class Child1 < Parent > def go > super > puts 'child1' > end > def a_method_id_like_to_inherit > end > end > > class Child2 < Child1 > def go > self.class.superclass.superclass.instance_method( :go ).bind( self > ).call > puts 'child2' > end > end > > Child2.new.go > ---------------------------- > parent > child2 > ---------------------------- > > Isn't there anything simpler than that? Or is that kind of pattern > considered as bad design maybe? Smells a little of bad design. Consider putting the common methods for Child1, Child2 into a module: class Parent end class Child1 < Parent include ChildStuff end class Child2 < Parent include ChildStuff end Just a suggestion -- it's hard to really comment on a design without knowing the problem you're trying to solve. --000e0cd248fa08e2da04630b0906--