From: Michal Suchanek Date: 2009-03-02T17:18:35+09:00 Subject: Re: Rub 1.9: "inline rescue" doesn't work? 2009/3/2 Gregory Brown : > On Sun, Mar 1, 2009 at 6:58 PM, Iñaki Baz Castillo wrote: >> Hi, is there any explanation for the folowing big difference between the same >> code in 1.8 and 1.9?: >> >> >> 1.8) >> >> aaa = 123.capitalize rescue 444 >> => 444 >> >> >> 1.9) >> >> aaa = 123.capitalize rescue 444 >> NoMethodError: undefined method `capitalize' for 123:Fixnum > >>> RUBY_VERSION > => "1.9.1" >>> 123.captialize rescue 444 > => 444 > > 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. Thanks Michal