Hal E. Fulton wrote:
> ----- Original Message ----- 
> From: "Dmitri Colebatch" <dim / colebatch.com>
>
>>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

Thanks - hadn't spotted the .nil? method.  I assume thats on Object.

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

yeah, the actual code had a fair bit of logic in it, so I wanted the 
block separation, but thanks all the same.

cheers
dim