Mathieu Bouchard <matju / sympatico.ca> writes: > On Sun, 5 Aug 2001, Dave Thomas wrote: > > > If you want to do type testing, you should really use > > #respond_to?, not #is_a?, as that way you'll make explicit the > > operations that you're asking your object to have. > > No, you'll make explicit the names of the operations, which is quite > close, but quite not. You can say this method only requires #[] but > it's not specified whether it's Array#[] or Hash#[], or the > VerySpecialThing#[] (whose semantics are not written down anywhere), > then knowing you need #[] only tells you half of what you need to > know. True, but in a dynamic language with open base classes I'm not sure I see a _viable_ alternative. > > Again, though, I'd question the usefulness of this. What is the > > benefit of having an application die with an assertion failure at the > > top of a routine, when it will fail anyway with a NameError a few > > lines down? > > Because a few lines down it may be too late. I don't want to be contentious, and I'm certainly willing to be swayed on this issue. Could you give a real-world example of this? Thanks Dave