Greg Willits wrote: > Gavin Kistner wrote: >> Greg Willits wrote: >>> In this play code below, I want to use initialize_colors in either the >>> class Shape or Square as a class method. >> >> Including a module in a class causes instance methods of the module to >> be in the lookup path for instances of the class. Extending a class >> using a module causes instance methods of the module to be in the >> lookup path for the class itself. >> >> (See http://phrogz.net/RubyLibs/RubyMethodLookupFlow.png) >> >> A common idiom to be able to cause a class to get both class and >> instance methods when including a single module follows: > > Cool, thanks. But... > > In this code the fill_color is still never set to black. It seems to me > that Module code even if added as class methods cannot access class > variables? OK, nevermind -- I get it now. even though they have the same name they are actually two independent variables in the two separate "name spaces/realms" of the model & class containers. I thought the "inclusion" would fuse the two spaces into one. -- gw -- Posted via http://www.ruby-forum.com/.