From: ara.t.howard@... Date: 2006-07-14T06:01:32+09:00 Subject: Re: equivalent of attr_accessor for class variables? On Fri, 14 Jul 2006, bwv549 wrote: > It is simple to set a class constant in ruby: > > class Foo > CLASS_CONSTANT = "never to change" > end > > And accessed like this: > Foo::CLASS_CONSTANT > > However, I'd like to be able to create a class variable that is easily > accessible (read/write) by outside users without having to write class > accessor methods. How can I do this? > > A really ugly way to set the variable without an accessor would be > this: > class Foo; @@class_constant = "newvalue" end > but that is write only. > > The syntax: > Foo.class_constant = "newvalue" > would be preferable, but how to do this without writing accessor > methods? > > Thanks class C class << self attr_accessor 'class_constant' end end -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama