From: Ken Bloom Date: 2009-03-03T00:38:55+09:00 Subject: Re: Rub 1.9: "inline rescue" doesn't work? On Mon, 02 Mar 2009 09:36:10 -0500, Gregory Brown wrote: > On Mon, Mar 2, 2009 at 3:18 AM, Michal Suchanek > wrote: >> 2009/3/2 Gregory Brown : > >>> But please, don't use this technique.  It creates huge debugging >>> nightmares. >>> >>> Instead, just do: >>> >>> aaa = obj.respond_to?(:capitalize) ? obj.capitalize : 444 >>> >>> >> I'd see it as a Ruby's failure that the proper check is against DRY. > > Agreed, but the costs of the elegance of using rescue as a conditional > modifier stack up fast in any moderately complex system. > > -greg The problem with the rescue modifier is that it lumps all types of errors into one relatively blunt tool. A rescue(Type) modifier would really help, and a ?. operator (like Groovy's) would resolve one of the most common cases for a rescue modifier. --Ken -- Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/