----- Original Message ----- 
From: <nobu.nokada / softhome.net>
To: ruby-talk ML <ruby-talk / ruby-lang.org>
Sent: Sunday, December 23, 2001 10:03 AM
Subject: [ruby-talk:29365] Re: a better way?


> At Sun, 23 Dec 2001 23:18:26 +0900,
> Henning von Rosen <henning / ikso.net> wrote:
> > BTW...so, if ruby was pythonish, 
> > """
> > class Temp
> >     Temp.farenheit = Hash.new do |h, c|
> >         puts "Performing calculation...."
> >         h[c] = c * 9 / 5 + 32
> > """
> > would be all the needed writing... :-)
> 
> Do you like this?
> 
>   module Temp
>     @farenheit = Hash.new do |h, c|
>       h[c] = c * 9 / 5 + 32
>     end
>     class << self
>       attr_reader :farenheit
>     end
>   end
> 
>   Temp.farenheit[100] # => 212
>   Temp.farenheit[200] # => 392

Oh, that is excellent. I wish I had thought
of that.

Hal