On Tue, 18 Oct 2005 20:34:05 +0200, Peter Fitzgibbons  
<peter.fitzgibbons / gmail.com> wrote:

> Hello all,
>
> I have this :
>
> def mymethod
>   a = someobjectreference('a')
>   if a.nil?
>     return nil
>   end
>   b = a.someattribute_might_be_nil
>   if b.nil?
>     return nil
>   end
>   c = b.someattribute_might_be_nil
>   if c.nil?
>     return nil
>   end
>   c.dosomething
> end

How about:

def mymethod
   if
   a = someobjectreference('a') and
   b = a.someattribute_might_be_nil and
   c = b.someattribute_might_be_nil
     c.dosomething
   else
     nil
   end
end

It isn't exactly the same, because it would also return nil if a, b or c  
were false instead of nil.

Dominik