From: Douglas Livingstone Date: 2005-06-12T02:03:13+09:00 Subject: Re: Only if the object exists On 6/11/05, Gavin Kistner 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