From: Joel VanderWerf Date: 2004-06-10T05:24:12+09:00 Subject: Re: accessing class instance variable from instance method Ara.T.Howard wrote: > On Wed, 9 Jun 2004 nobu.nokada@softhome.net wrote: > >> Hi, >> >> At Wed, 9 Jun 2004 13:10:52 +0900, >> David Garamond wrote in [ruby-talk:102895]: >> >>> I know there might be some cases where you want to share your class vars >>> with the subclasses, but I usually want a per-class class variables. >>> >>> I believe this will change in Ruby2. >> >> >> It was changed in 1.9. >> >> -- >> Nobu Nakada > > > so - does a concept of 'inherited class variable' exist in 1.9 then? i > actually use these from time to time... I did too, until I saw Nobu's note today. I'm going thru all my code and replacing inherited class vars with accessors to class vars (protected, if need be): class C @history = [] class << self attr_reader :history end end class D < C def foo C.history << "D#foo" end end d = D.new d.foo p C.history I like how "C.history" is explicit about which class's var is being accessed, whereas @@ was always ambiguous, depending on initialization order.