From: Sean O'Halpin Date: 2007-11-16T09:16:26+09:00 Subject: Re: Yielding an object and caring about the result: the cousin of Object#tap On Nov 13, 2007 10:05 PM, -a wrote: > i also typically prefer > > response = http.response > response.foo > response.bar > > to > > http.response.foo > http.response.bar > > for two reasons > > 1) error reporting > 2) vars are cheap in ruby, function calls are not > > although for simple/short code i do use the second often, reserving > the former for 'real' code i anticipate maintaining and debugging. i > suspect i'm in the minority here. > Me too, though that may be an ancient aversion to null pointers in structure member dereferencing in C as in some->null_pointer->in_the_middle->of_a_chain I also find myself using this pattern: if response = http.response # i.e. expecting nil or false on failure response.foo # etc. else ... end Your point on avoiding unnecessary method calls is well-made - there's no telling how much an intermediate call may cost - why repeat it? Regards, Sean