From: Meino Christian Cramer Date: 2003-09-13T19:56:41+09:00 Subject: Re: Duck Typing From: Dan Doel Subject: Re: Duck Typing Date: Sat, 13 Sep 2003 18:57:25 +0900 > You really shouldn't use #is_a? or #respond_to? much at all. That's not what > duck typing is about. > > Just write your method to use methods that the passed in object should > have, by > the contract of the method. Then test to make sure your program works. > > Excessively using #is_a? and #respond_to? is essentially trying to turn ruby > from a dynamically typed language into an ad-hoc statically typed language, > which isn't in the spirit of duck typing at all. > > The only real reason you should be using these methods is if you need to > take different actions depending on which of several methods is available. > If you're just checking whether the only method you use exists or not, > you're > just doing extra work most of the time. The interpreter will tell you if it > isn't there. > > It can be a confusing issue if you haven't read the discussions before. > There > was a big one some weeks back, so it might be worth it to read the ruby-talk > archives to clear some stuff up without duplicating all of it again. > > Cheers. > > - Dan > > > Thanks for your reply, Dan...will go to the archives ! Kind regards, Meino