From: Jason Roelofs Date: 2008-02-28T00:32:36+09:00 Subject: Re: Question about how ruby sources is parsed That's weird looking stuff, I can't imaging that it's good to do thing that way. What's wrong with class String def foo 123 end end ? Jason On Wed, Feb 27, 2008 at 10:19 AM, ThoML wrote: > Hi, > > I recently came came up with this piece of (monkey-inspired) code: > > class String0 < String > def foo > 123 > end > end > > Object.send :remove_const, :String > String = String0 > > This makes the following two statements work as intended: > > p String0.new("foo").foo # => 123 > p String.new("foo").foo # => 123 > > The following doesn't work though: > > p "foo".foo > p eval %{"foo".foo} > > undefined method `foo' for "foo":String (NoMethodError) > > Has somebody an idea if it is possible to make the ruby parser use > the > new String class somehow? I assume there is no way to make this work > but > then: I'd be happy if somebody proves me wrong. > > Regards, > Thomas. > > >