[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: duck-typing allows deeper polymorphism

Devin Mullins

6/10/2005 3:07:00 PM

> > Not entirely true... The argument 'x' must also respond to whatever
> > parseargs wants from it (respond_to?, I assume), whatever the 'pa.x' method
> > wants from it (well, nothing, I assume), and whatever 'p' wants from it
> > (to_s, I assume).
>
> sure - everything in :ducktype=>list AND what parseargs needs - quite true.
Not just parseargs, but any other methods that the method calls. In your case, it was simply p, but in some other case, I might be passing a parameter all around the system, in which case, who knows what it'll need. (Is that bad design? If so, that's precisely one of the things I want to flesh out as an extra restriction we need to place on ourselves because we're using Ruby.)

> >> note that this could be parsed via rdoc quite easily.
> > Only if it's an Array literal being passed to parseargs.
> huh?
def method(*argv)
pa = parseargs(argv){
arg :x, :ducktype => File.new('methods.txt').readlines.each { |line|
line.chomp
}
}
p pa.x.upcase.downcase
end

> we're all friends here so i assume people will offer up any criticisms come to
> mind.
Ok. Thanks!

Devin




1 Answer

Ara.T.Howard

6/10/2005 5:06:00 PM

0