From: Robert Dober Date: 2008-07-21T23:22:38+09:00 Subject: Re: protected members or explicit abstract classes? On Mon, Jul 21, 2008 at 2:37 PM, David A. Black wrote: > Hi -- > For true duck typing you would just do: > > s.the_method In the general case thats seems clumsy to me, I'd rather check if a protocol is implemented. A very simple example is an IOArray I use to capture output, it mocks two file methods #puts and #<<. What would you prefer? raise Whatever unless o.replies_to?( :puts ) && o.replies_to?( :<< ) raise Whatever unless o.implements_behavior? IOArray # but the name is bad Now imagine the protocol has five or even 10 methods? Maybe it might also be helpful to recall the definition of duck typing: "If it walks like a duck and talks like a talk...", this is about behavior and not about methods. My journey - that was long and would not have been so productive were it not for this list - has brought me to search out for new expressiveness of behavior and I pretty much like traits most right now. But I am still open to walk on ;). Cheers Robert -- http://ruby-smalltalk.blogspot.com/ There's no one thing that's true. It's all true. -- Ernest Hemingway