From: "Hal E. Fulton" Date: 2001-12-23T10:23:18+09:00 Subject: [ruby-talk:29331] Re: a better way? ----- Original Message ----- From: David Alan Black To: ruby-talk ML Sent: Saturday, December 22, 2001 7:07 PM Subject: [ruby-talk:29328] Re: a better way? > Hi -- > > On Sun, 23 Dec 2001, 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? > > You could do: > > result = @@save[self] and return result Or the C-like: if result=@@save[self] then return result end I don't fully understand your application, but I'm assuming you *don't* want to return a nil and check for it in the caller... otherwise, of course, you could just do: return @@save[self] Just my $0.01, Hal