On 6/11/05, Gavin Kistner <gavin / refinery.com> wrote:
> If I write code like this:
>    self.foo.bar if self.foo
> then ruby runs the #foo method twice. (Javascript is the same way.)
> 

I'd probably go for:

result = foo
result.bar unless result.nil?

If it has to go one one line, could be:

t = foo and puts t.bar

but you still have the temp var.

Douglas