Ben Giddings said:
> 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.

You're correct.  If you need an object to respond to, say, 3 different
methods, then you should check to see that it responds to those three
methods (if you aren't confident that it will) - no more and no less than
the three that you need.

If the object responds to the methods that you need, then there's no
reason for it to have to be of a specific type/implement a specific
interface.  It does what you need it to do & that's all you should care
about.

At least, this is how I understand the concept of Duck Typing...

-Ryan


-- 
Ryan Dlugosz
ryan / dlugosz.net

http://dlugosz.net