Hi --

On Fri, 8 Aug 2003, Mills Thomas (app1tam) wrote:

> I checked out some of the new Ruby features at theluckystiff.net and saw
> 'ducktype'ing.  It sounds uber cool.  Is this what is meant by ducktype?
> (The code may be inelegant; I don't know; I'm still a Ruby Nuby).  Please
> correct me if I got it wrong.

Welcome to Ruby!

I would describe "duck typing" not as a particular programming
technique, but as a way of understanding how Ruby objects present
themselves with regard to the notion of type.  Any Ruby object has
the potential to be customized, so to speak, as to its behavior and
interface.  So there's a kind of circularity, when it comes to
describing the type of an object: an object is of type
"the type which is the type of objects that behaves the way this object
behaves".  Hence (as I understand it) the idea of "duck typing": if it
behaves (walks, quacks, etc.) like a duck, then it's a duck.

(I guess one could take circularity even further and say: if it walks
and quacks like a duck, then it can be said to walk and quack like a
duck :-)

[...]

> This is sort of like having a discovered mixin.  Neat.
                              ^^^^^^^^^^^^^^^^^^

Intriguing phrase.  What do you mean exactly? :-)


David

-- 
David Alan Black
home: dblack / superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav