From: "Hal E. Fulton" Date: 2003-01-21T08:51:01+09:00 Subject: Re: Local variable scope ----- Original Message ----- From: "Dmitri Colebatch" To: "ruby-talk ML" 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