From: ara.t.howard@... Date: 2006-12-07T02:00:03+09:00 Subject: Re: Calling super in overwritten methods On Wed, 6 Dec 2006, Joerg Diekmann wrote: > Hi - not sure if this is possible - but it feels like it could be with > some serious ruby-fu. > > I have the following: > > class A > def method1 > method2 > end > > def method2 > return 100 > end > end > > class B < A > def method1 > super > end > > def method2 > return 200 > end > end > > > This is what happens: > > b.method1 # 200 > > But, what I want is: > > b.method1 # 100 > > > Is this possible at all? harp:~ > cat a.rb class A CLASS = self def method1 *a, &b CLASS.instance_method(:method2).bind(self).call *a, &b end def method2 return 100 end end class B < A CLASS = self def method1 super end def method2 return 200 end end p A.new.method1 p B.new.method1 harp:~ > ruby a.rb 100 100 just because you can, however, doesn't mean you should. why do you want to do this? -a -- if you want others to be happy, practice compassion. if you want to be happy, practice compassion. -- the dalai lama