From: Carlos Date: 2001-12-23T11:01:17+09:00 Subject: [ruby-talk:29334] Re: a better way? > class Temp > @@save = {} > def fahrenheit(c) > result = @@save[self] and return result > puts "Performing calculation...." > @@save[self] = c * 9 / 5 + 32 > end > end > > t = Temp.new > > puts t.fahrenheit(100) # "Performing calculation....\n212" > puts t.fahrenheit(100) # "212" puts t.fahrenheit(300) # "212" Ooohh!! ;)