From: HarryO Date: 2001-12-23T11:16:58+09:00 Subject: [ruby-talk:29337] Re: a better way? On Sun, 23 Dec 2001 12:46:10 +1100, David Alan Black wrote: > 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" As usual, I'm probably missing something obvious here, but shouldn't the index used to access @@save be "c" rather than "self", in both cases?