From: Robert Klemme Date: 2005-02-24T23:55:11+09:00 Subject: Re: a new delegation technique :-) "David A. Black" schrieb im Newsbeitrag news:Pine.LNX.4.61.0502240635380.25193@wobblini... > Hi -- > > This probably lies somewhere between obfuscated and pointless, LOL - I have to make a note for this localization. :-) > but I > thought it was a fun example of Ruby's nimbleness: > > > class C > attr_reader :to_s > def initialize(str) > @to_s = str > end > end > > s = C.new("hello") > puts s # hello > > :-) With the added class C alias :to_str :to_s end You can even do this: >> /ll/ =~ s => 2 :-)) robert