From: "David A. Black" Date: 2007-05-02T08:26:54+09:00 Subject: Re: simple subclass question Hi -- On 5/1/07, Ball, Donald A Jr (Library) wrote: > Thanks to you and Robert for the quick answers. I think I get it now; I > was a little fuzzy on the notion of class instance variables before. I > now use a construct like so: > > class A > class << self > attr_accessor :var > end > end > > class B < A > class << self > def var > @var || superclass.var > end > end > end > > to allow subclasses's instance variables to default to their > superclass's until and unless overridden. I'll admit the class << self > syntax continues to mystify somewhat; can anyone proffer an explanation > that would help me grok it fully? Possibly; have a look at: http://www.rubypal.com/singletons.html David -- Upcoming Rails training by Ruby Power and Light: Four-day Intro to Intermediate May 8-11, 2007 Edison, NJ http://www.rubypal.com/events/05082007