[Squeak-fr] Ruby et les Traits.

Giovanni Corriga giovanni at corriga.net
Tue Oct 23 08:01:09 UTC 2007


Il giorno mar, 23/10/2007 alle 07.02 +0200, Jason Johnson ha scritto:
> But since these two systems are so similar what places are modules
> used in Ruby to the best effect?  I always used Haskell as my
> comparison, but it turns out this isn't a good idea because Haskell
> isn't an OO language, so the applicability is different.

An example of module use in the Ruby standard library is the collections
system. Ruby doesn't have an abstract Collection class that acts as the
superclass for all collection classes, but it has an Enumerable module
that implements methods such as #select, #collect, #inject, etc. All
these methods depend on the including class implementing #each (#each is
the Ruby equivalent of #do: ). All the concrete collection classes have
an #each method and include Enumerable in order to support the complete
collection protocol.

	Giovanni




More information about the Squeak-dev mailing list