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'm assuming :ameth and ameth are meant to be a Symbol and String
respectively, otherwise the 2nd and 3rd calls would be meaningless since the
call to respond_to? would have failed so

respond_to? :ameth and ameth and not ameth.to_s.empty? ...

short ciruits the same way.  not that short... but potentially one line.

it's hard to envision why simply

  ... if respond_to ameth

would not suffice though?  why have :ameth and ameth?

-a


-- 

 ====================================
 | Ara Howard
 | NOAA Forecast Systems Laboratory
 | Information and Technology Services
 | Data Systems Group
 | R/FST 325 Broadway
 | Boulder, CO 80305-3328
 | Email: ahoward / fsl.noaa.gov
 | Phone:  303-497-7238
 | Fax:    303-497-7259
 ====================================