From: Alexandru Popescu Date: 2005-08-21T11:02:25+09:00 Subject: include and extend Module - Ruby Way Hi! I am reading the excellent The Ruby Way. I most probably not understand correctly the following pieces: [quote page=38] With include, the module's methods become available as instance methods; with extend, they become available as class methods [/quote] I have written the following code example: [code] module ExampleModule def moduleMethod puts 'module method' end end class IncludeModule include ExampleModule end class ExtendModule extend ExampleModule end im = IncludeModule.new # IncludeModule.moduleMethod # this is correct im.moduleMethod # module method becomes instance method em = ExtendModule.new ExtendModule.moduleMethod # module method becomes class method em.moduleMethod # this is failing! WHY? [/code] As pointed above the em#moduleMethod is failing. Being a class method I expect it to be available also on every instance. What I wrongly understood? Later I can read the following: [quote page=275] The extend method will mix a module into an object. The instance methods from the module become instance methods for the object. [/quote] Isn't this in contradiction with the first quote? Please enlighten me. :alex |.::the_mindstorm::.|