----- Original Message ----- 
From: "Dmitri Colebatch" <dim / colebatch.com>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Monday, January 20, 2003 5:35 PM
Subject: Re: Local variable scope


> I tried to do this yesterday:
> 
>    def foo(foobar)
>      bar = 0;
>      if foobar != nil
>        bar = foobar * 4
>      else
>        bar = "foobar!"
>      end
>      bar
>    end

This should work fine. Offhand I'd say the problem
you're having must be of a different nature.

There are shorter/prettier ways, depending on
your individual taste:

E.g.:

def foo(foobar)
  if foobar.nil?
    foobar*4
  else
    "foobar!"
  end
end

Or even:

def foo(foobar)
  foobar ? foobar*4 : "foobar!"
end


Cheers,
Hal