From: Hal Fulton Date: 2003-09-13T17:13:17+09:00 Subject: Re: Duck Typing Meino Christian Cramer wrote: > From: dblack@superlink.net > Subject: Re: Duck Typing > Date: Sat, 13 Sep 2003 10:29:52 +0900 > > Hi, first of all: I am very happy to have a programming language with > such a communicative and friendly mailinglist!!! :) > > GREAT! > > (Whether it will be a good idea or not to mirror the posts into a newsgroup > -- we will see. Previously I had made bad experiences, since my email > postbox was overloaded with spam. Spammers do scan newsgroups for > addresses... but this is quite another topic...) > > Back to the ducks ! > > >>Or even, more generally, left with the impression that there's an >>on/off switch: if you say "is_a?" a lot, then you're not doing duck >>typing, whereas if you say "respond_to?" a lot, then you are -- when >>in fact it's really Ruby that's doing the duck typing, and you're >>just deciding how to react to it. > > > If both works: is_a? and respond_to? : What is the advance of one > over the other beside the fact, that one has a cool name : "Duck > typing"? > > Is one slower, less clean or ... ? I am just curious... Don't misunderstand. David is saying that this is *some* people's impression of what duck typing means. Note the second part: "--when in fact it's really Ruby that's doing the duck typing, and you're just deciding how to react to it." It's not a coding style or technique; it's an attribute of the language. Hal