From: Gregory Brown Date: 2008-08-01T02:53:10+09:00 Subject: Re: super with block On Thu, Jul 31, 2008 at 1:47 PM, Lou Zell wrote: >> your problem has nothing to do with passing the block along in gsub! >>>>> s = NString.new("hi") >> guess what s is here? >> If you guessed "", you guessed correctly > > Wait, why would s be empty? I can use Nstring.new just like String.new > >>> class Nstring < String >>> end > => nil >>> n = Nstring.new("hi") > => "hi" >>> puts n > hi Same here: seltzer:~ sandal$ ruby -v ruby 1.8.6 (2008-06-20 patchlevel 230) [i686-darwin8.11.1] seltzer:~ sandal$ irb >> class NString < String >> end => nil >> n = NString.new("hi") => "hi" >> puts n hi That having been said, I generally avoid sub-classing core Ruby objects because I think some of them use optimizations that cause internal C methods to be called rather than the methods of a subclass, resulting in strange behaviour. That having been said, I don't know that I've ever seen it in practice. Does anyone have an example of this, or am I just being paranoid? -greg