From: John W Higgins Date: 2010-09-16T05:39:34+09:00 Subject: Re: access super from yield block? --0014853932ba031a6d049052532c Content-Type: text/plain; charset=ISO-8859-1 Afternoon, On Wed, Sep 15, 2010 at 1:12 PM, Gene Angelo wrote: > > What exactly are trying to achieve? > > I have class A that derives from class B > > A#parse and A#parse! override members of the same name in B > > A#parse and A#parse! both call A#do_parse to retrieve arguments from the > command line in a loop. A yield in A#do_parse returns the arguments > (argv). I want to call 'super argv' from both A#parse and A#parse! but > super is not set to A#super. > > How about something like this - a little hokey but it works class A def x(parm) puts "Hi from A - #{parm}" end end class B < A alias :super_x :x def x(parm) puts "Hi from B - #{parm}" do_something { |z| super_x(z) } end def do_something yield "Hello" end end The alias will in essence give you the super method so you can use it inside the block. John --0014853932ba031a6d049052532c--