From: "Florian Groß" Date: 2005-04-04T23:31:50+09:00 Subject: Re: Ruby rite (Ruby 2.0) vaporware or real? Richard Cole wrote: > My major gripe with Ruby is that there's no static typing. I'd really > like to be able to do something like: > > interface ISubject > def notifyAll -- unit > def addObserver(a -- IObserver) -- unit > end > > interface IObserver > def subjectUpdate(subject -- ISubject) > end > end > > class Subject > def initialize > @observerList -- ISubject IEnum = Array.new() > end > ... > end > > Why? because interfaces gives you a place define and explain protocols > of interaction. It also helps out the IDE, when you type @observerList > the IDE knows the type and can do name completion on it, hyperlink your > code etc. > > Also interfaces inheritance is very different to reuse inheritance. It > is so much clearer intentwise for a framework if the interfaces are > explicit, rather than being implicit. > > The major problem with interfaces is that you can't say later, oh, this > class implements that interface, but in Ruby, if there were interfaces, > the you could. Please have a look at my ruby-contract library which offers this and more: http://ruby-contract.rubyforge.org/