From: Robert Klemme Date: 2006-09-21T00:20:13+09:00 Subject: Re: [ANN] Ducktator - A Duck Type Validator On 20.09.2006 16:37, Ola Bini wrote: > Austin Ziegler wrote: >> On 9/19/06, Ola Bini wrote: >>> Actually, the name is more about the fact that you can use regular >>> duck-type techniques (like respond_to?), >> >> Note: if you're calling #respond_to? you're not doing duck typing. >> You're doing contract validation, perhaps, but not duck typing. Duck >> typing is just calling a method and expecting that it will be >> implemented. It's *trusting* your callers to do the right thing. >> >> Now, I sometimes use #respond_to? -- but it isn't duck typing. > > I beg to differ, and according to the pick-axe, this interpretation is > correct. Duck-typing isn't to *trust* your callers. Duck typing is to > check if something quacks like a duck and walks like a duck. Definitively not. What do you do if that method returns false? Basically you can only raise an exception. Of course, you can use a different exception type and message but that's it. If you need respond_to? to choose a different path of execution because a method needs to cope with different types that's ok but it's not duck typing. Regards robert