From: Dave Thomas Date: 2003-09-15T13:25:31+09:00 Subject: Re: Duck Typing On Friday, September 12, 2003, at 07:23 PM, Jim Weirich wrote: >> What Duck typing is based mostly on realising what sort of operations >> you want to do with the object and testing for those operations, >> rather than testing for the class. As Dave is fond of saying: type and >> class aren't the same. > vs > > Duck typing is based mostly on realising what sort of operations > you want to do with the object and just doing them, rather than > worrying if the object inherits from the proper base class or > interface. > OK - it's my phrase, so I get to referee :) You're both right, depending on the context. Duck typing is as Jim describes in his example. It's what an object does, not its lineage, that determines its type. However, some folks feel compelled to check the types of the parameters passed to methods. When this is done, and when you're testing for capability, then you should test by checking the object's supported methods, not its type. Cheers Dave