From: dblack@... Date: 2005-12-23T02:40:57+09:00 Subject: Re: String > Integer Conversion Problem Hi -- On Fri, 23 Dec 2005, Joel VanderWerf wrote: > dblack@wobblini.net wrote: > >> begin >> obj.meth >> rescue NoMethodError >> >> end [Did I really indent by only 1? It must have been early in the morning... :-] > This has the unfortunate side effect of conflating NoMethodErrors that > are reported for other method calls besides the original obj.meth but > which occur during that method. What's the best way of handling that? > Compare exception.backtrace depth with the current backtrace depth? I guess, but it gets awfully cluttered. I don't know what the best way is. Too bad exceptions don't have a depth property or something.... > It's not really threadsafe either. By the time is > executed, #meth could have been defined (though you do know it was > undefined at the time of the method call, which is an improvement over > the #respond_to version). I guess in a sense anything non-atomic is non-threadsafe, but here at least you know there won't be a fault-line between knowing whether the object responds to the message, and asking it to do so. The method call happens all at once, and then everything else sort of falls away from that. David -- David A. Black dblack@wobblini.net "Ruby for Rails", from Manning Publications, coming April 2006! http://www.manning.com/books/black