From: "Jesús Gabriel y Galán" Date: 2008-07-31T18:55:41+09:00 Subject: Re: super with block On Thu, Jul 31, 2008 at 11:06 AM, Lou Zell wrote: > Hi all, > > I'm looking for a bit of help. I can't seem to get the block to "pass > through" to the parent class. I figured without an '&' in the parameter > list there would be no conversion to proc but maybe that is not the > case. > > class Nstring < String > def gsub!(*args) > super > end > end > > This works as I expected: > > s = Nstring.new("hi") > s.gsub!(/(hi)/,'\1') > => "hi" > > But this, not so much: > > s.gsub!(/(hi)/) {$1} > => "" > Hi, This worked for me: irb(main):023:0> class NString < String irb(main):024:1> def gsub!(*args, &blk) irb(main):025:2> super(*args, &blk) irb(main):026:2> end irb(main):027:1> end => nil irb(main):028:0> s = NString.new("hi") => "hi" irb(main):029:0> s.gsub!(/(hi)/){$1} => "hi" Hope this helps, Jesus.