----- Original Message ----- 
From: David Alan Black <dblack / candle.superlink.net>
To: ruby-talk ML <ruby-talk / ruby-lang.org>
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