From: David Alan Black Date: 2001-12-23T11:26:58+09:00 Subject: [ruby-talk:29339] Re: a better way? Hi -- On Sun, 23 Dec 2001, HarryO wrote: > 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? You're not missing anything. See my previous post (which introduced a semblance of functionality to my original garbage, in a somewhat different way). David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav