On Fri August 8 2003 1:25 pm, Dave Thomas wrote:
>      fred << "dog"
> 
> in Ruby, I don't care whether fred is a String, a File, or an Array (a 
> fact that's very useful when writing unit tests).

The one thing that I think is underemphasized about the duck typing concept is 
that just because something floats, it might not be a duck (it might be a 
witch!)

In Java you could check to see if something is of a certain class, but what 
was more often done was to see if something implemented a certain interface.  
Implementing an interface was a way of signalling "I declare myself to act 
like a duck".  And the fact you implemented the interface meant that you had 
all the necessary features to act like a duck.  You weren't allowed to 
implement the interface and then only choose certain duck-like features.

It seems to me that duck-typing in Ruby should strive for the same thing.  
Checking for one method isn't enough, in my opinion.

Ben