On Aug 9, 2010, at 6:37 PM, Markus Fischer wrote: > Hi, > > On 09.08.2010 22:46, Rob Biedenharn wrote: >> Or, if you want to use a module to hold methods to be mixed in to >> another class: >> >> irb> module Test >> irb> def yo >> irb> puts 'yo' >> irb> end >> irb> end >> => nil >> irb> class Toy >> irb> include Test >> irb> end >> => Toy >> irb> Toy.new.yo >> yo >> => nil > > Interesting example. Is there another way to "access" or "make use" of > "yo" besides including the module in a class? Or putting it another > way: > can I call yo directly when being defined that way? > > thanks > Well, hard you know what you mean, but does this help: irb> hi = "hello" => "hello" irb> hi.extend Test => "hello" irb> hi => "hello" irb> hi.yo yo => nil A Module is like a Class in most respects except that it cannot be instantiated. (So there's no Test.new for that module Test.) You can include a Module into a class to have its methods appear in the lookup path for instances of that class. Or you can extend any object like I did above. You should try things out in irb and then ask questions when your attempt to read the docs and understand the behavior fall short. -Rob Rob Biedenharn Rob / AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab / GaslightSoftware.com http://GaslightSoftware.com/