From: Chad Fowler Date: 2001-12-23T11:16:57+09:00 Subject: [ruby-talk:29336] Re: a better way? Ron Jeffries wrote: > I was writing a little code that cached a function value, and wound up > with this: > > result = @@save[self] > return result if result > > I don't see a way to do it in one line unless I'm willing to do the > lookup twice. Am I missing something? > I'm sure this is complete overkill for what you're looking for (since you were wanting to fit it into a single line), but I thought it was worth a mention that Robert Feldt has created something called "memoize": http://www.ce.chalmers.se/~feldt/ruby/extensions/memoize/ Chad