From: dblack@... Date: 2003-01-17T10:35:32+09:00 Subject: Re: quick: it responds, it evaluates, and is not empty Hi -- On Fri, 17 Jan 2003, Tom Sawyer wrote: > quick quest: anyone know of a nice slick short and sweet way to do this: > > if self.respond_to?(:ameth) > if ameth > if not ameth.to_s.empty? > ... > end > end > end I think it's probably worth having a temp variable here to avoid calling the method an extra time: if respond_to?(:ameth) if (a = self.ameth) unless a.to_s.empty? ... end end end or Boolean operator-wise (see other reply): if respond_to?(:ameth) && (a = self.ameth) &&! (a.to_s.empty?) ... end or some combination. I continue to dislike the repetition of the if obj.respond_to?(:meth) then obj.meth ... thing, although I don't know how to circumvent it efficiently and effectively. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav