A new delegation technique :-)

Hi --

This probably lies somewhere between obfuscated and pointless, 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

:slight_smile:

David

···

--
David A. Black
dblack@wobblini.net

Ah.

I would put it in the pointfuscated group.

James

···

On Thu, 24 Feb 2005 23:37:26 +0900, David A. Black <dblack@wobblini.net> wrote:

Hi --

This probably lies somewhere between obfuscated and pointless, 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

:slight_smile:

"David A. Black" <dblack@wobblini.net> 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. :slight_smile:

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

:slight_smile:

With the added

class C
  alias :to_str :to_s
end

You can even do this:

/ll/ =~ s

=> 2

:-))

    robert

In article <Pine.LNX.4.61.0502240635380.25193@wobblini>,

···

David A. Black <dblack@wobblini.net> wrote:

Hi --

This probably lies somewhere between obfuscated and pointless, 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

:slight_smile:

Cool.

I read the subject of your post and thought that perhaps you were going to
ask if someone else would organize RubyConf this year :wink:

Phil