From: Daniel Schierbeck Date: 2006-05-28T18:19:21+09:00 Subject: Re: Crazy thought -- Rubyish type conversion? Farrel Lifson wrote: > It will make catching exception on type 'conversion' a bit hard. How > would you handle: > > irb(main):001:0> 1.05.to_sym > NoMethodError: undefined method `to_sym' for 1.05:Float I'm not sure where you're getting at -- there should be raised either a NoMethodError or an ArgumentError. I'm not sure what's best, but I can't see what the big deal is. One thing that might need some though is whether a rescue clause on the method definition should rescue exceptions raised when an argument doesn't respond to the conversion method, i.e. def test(str foo) # blah rescue ArgumentError # or NoMethodError puts "dude, you gotta give it a string..." end Daniel