From: Sean DeNigris Date: 2010-02-01T02:30:10+09:00 Subject: Re: Inheritance related problem > When Parent's printa is called, it calls its own printb. > However, when Child's printa is called, it calls Parent's printa, which > (in this case) i was hoping would call Parent's printb directly. But it > (correctly) calls Child's printa which once again reduces the arg. > > So my arg gets reduced twice. I suppose i could use some flags to > prevent this, But is there any direct way i can coerce Parent printa to > call only Parent printb. I'm having trouble understanding how you got into this position. I'm assuming that you don't own Parent, and so have to work your magic in Child. For the specific example you described, the following will work... Change Child#printa to: def printa arg # The following block gets evaluated with Child as self child_print_b = Child.class_eval do # Save the Child method print_b = instance_method(:printb) # Remove it from the class remove_method :printb # Return it to the function for later restoration print_b end puts "inside child printa #{arg} reduced 1 " # 1 is actually some other instance level variable # This call will now eventually call Parent.printb # because there is no Child.printb super arg-1 # Restore the original printb Child.class_eval do define_method :printb, child_print_b end end Outputs: parent calls with 5 inside parent printa 5 inside parent printb 5 --> 5 === child calls with 7 === inside child printa 7 reduced 1 inside parent printa 6 inside parent printb 6 <-------- Parent::printa called from Child::printa calls Parent::printb --> 6 inside child printb 7 reduced 1 inside parent printb 6 --> 6