[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

classes within a module?

aidy

5/28/2007 5:31:00 PM

Why do Rubyists generally hold a number of classes within a module?

cheers

aidy

1 Answer

John Wilger

5/28/2007 5:44:00 PM

0

On May 28, 10:31 am, "aidy.le...@googlemail.com"
<aidy.le...@googlemail.com> wrote:
> Why do Rubyists generally hold a number of classes within a module?

If you're working on a library to do X, and I'm working on a library
to do Y, and someone else wants to use both libraries in his
application; if we each put our code inside XStuff and YStuff,
respectively, then he won't have to worry about whether we both use a
class named Foo for unrelated purposes. Otherwise, the open classes in
ruby would mean that one definition might trounce parts of another and
neither one would likely work correctly except by luck.

There are other reasons for putting classes in a module, but this is
likely the main one. (Although there are other uses for modules as
well -- especially for use as mixins).

--
Regards,

John Wilger