From: Robert Klemme Date: 2006-08-12T22:50:08+09:00 Subject: Re: Modules -> do I have is straight? Carl Jenkins wrote: > I was hoping I could expand on the thread a little bit... > > I sort of understand modules, according to what I have read in my > fancy ruby book and this forum modules are like superclasses. But, > what about this < ? > Doesn't this allow a class to "become" a subclass of another by way of > inheritance. Not sure I am catching the difference between the two. class Base end class Descendant < Base end Descendant is a subclass of Base. module Foo end class Bar include Foo end Foo is mixed into Bar. You can combine both approaches. class Deri2 < Base include Foo end Deri2 inherits Base and mixes in Foo. You can use instance methods from Base and Foo in Deri2. > Also, I am not quite sure I understand how namespaces works in ruby. > In java you create a package ( i know you all know this already I am > just saying it for my benefit) to place related classes in. Say for > example com.jenkins.util.MyFancyClass. If I want to use this class in > another package com.jenkins.library any classs in library would just > import it. How does this work in ruby? module com module jenkins module util class MyFancyClass end end end end Now you have com::jenkins::util::MyClass Or you do include com::jenkins::util MyClass > Most of the code I have seen is in the same class or at least the same > direcctory. Is it typical for ruby applications to create a package > structure similar to a java app? You can do that. From what I've seen though these hiearchies are not as deep as they are usually in Java. Kind regards robert