From: Martin DeMello Date: 2003-08-08T07:27:08+09:00 Subject: Re: Ducktype, right? "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. > > def ducktype (x, y) > !(!( x.map{|f| break false if !y.respond_to?(f) })) > end More elegantly in 1.8 x.all? {|f| y.respond_to?(f)} martin