From: Pit Capitain Date: 2007-03-17T01:49:25+09:00 Subject: Re: java guilt Trans schrieb: > I wrote an experimental lib a while back that let you sub in your > class for another within the scope of another module/or class. I think > it's a pretty easy way to work with this concept. Far-sight better > than the clock based approaches, IMO. The central idea is: > > class InBlanket > > # This would have a even nicer DSL. > > String = Class.new(::String) do > def to_s; "(" + super + ")" > end > > def tryme > puts "three pigs" > end > > end > > InBlanket.new.tryme #=> "(three pigs) > > This could actually be made to work fairly easily *if* literals used > the ::new methods. Unfortunately they don't. So one would have to do > back and use String.new instead of "". I consider this a design flaw > in Ruby current implementation, though I'm sure there are > justifications for it (probably execution speed related). Tom, what would happen in your implementation if I pass a string from the outside to tryme? And what would happen if I use a string created in InBlanket outside of the class? Regards, Pit