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


Nobu Nakada