Hi,

I'm going to give you a meta-answer to the problem...

If the two printb routines do the same thing, then child printb is 
redundant. Remove it.

If they do different things, then they should have different names - 
problem avoided.

I don't know enough ruby to answer your specific problem.  

Regards

Ian

R. Kumar wrote:
> Note: this is *not* a ruby bug. its a general query.
> Perhaps best explained with sample code.
>
> #!/usr/bin/env ruby -w
>
> class Parent
>   def printa arg
>       puts "inside parent printa #{arg} "
>       printb arg
>   end
>   def printb arg
>       puts "inside parent printb #{arg} "
>       puts "--> #{arg} "
>   end
> end
>
> class Child < Parent
>   def printa arg
>       puts "inside child printa #{arg} reduced 1 "
>       # 1 is actually some other instance level variable
>       super arg-1
>   end
>   def printb arg
>       puts "inside child printb #{arg}  reduced 1"
>       super arg-1
>   end
> end
>
> if __FILE__ == $0
>   begin
>       p = Parent.new
>       c = Child.new
>       puts " parent calls with 5 and 6"
>       p.printa 5
>       #p.printb 6
>       puts " === child calls with 7 === "
>       c.printa 7
>       #c.printb 7
>   ensure
>   end
> end
>
>
> Class Child extends Parent. It extends 2 methods by modifying the
> incoming parameter and then calling super. One of these methods printa
> calls printb.
>
> When Parent's printa is called, it calls it 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.
>
> When you execute the above code, you will see that 7 gets decremented 2
> times.
>
> Attachments:
> http://www.ruby-forum.com/attachment/4448/test.rb
>
>   
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 9.0.733 / Virus Database: 271.1.1/2657 - Release Date: 01/30/10 07:35:00
>
>