On Apr 6, 4:12 pm, John Lane <li...@ruby-forum.com> wrote: > Hi, I'm playing around with module instance variables. I can set one up > and initialise it when the module is included in a class. What I can't > work out is how I initialise one when a class inherits another class > that includes the module. > > Seehttp://pastie.org/905720 > > This creates two classes, the first inherits a module that contains an > instance variable. The second inherits the first. The instance variable > in the first class is initialised as expected, the second (inherited > one) is not. The output I get is below: > > the data for class One is Tue Apr 06 15:10:43 +0000 2010 > the data for class Two is
You've got class instance variables which (unlike class variables) aren't shared around the inheritance hierachy at all. This is a slightly murky area which I wrote a bit about here: http://www.spacevatican.org/2008/8/19/fun-with-class-variables Searching for class instance variables should also turn up some interesting reading material. Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.