From: Bertram Scharpf Date: 2007-10-08T00:28:11+09:00 Subject: Re: Is using attr_accessor for class variables possible? Hi, Am Sonntag, 07. Okt 2007, 22:56:54 +0900 schrieb David A. Black: > On Sun, 7 Oct 2007, Bertram Scharpf wrote: >> Am Sonntag, 07. Okt 2007, 21:39:24 +0900 schrieb David A. Black: >>> If you want to represent state per class, the best way is to give your >>> class an instance variable or accessor: >>> >>> class C >>> class << self # C's singleton class >>> attr_accessor :var >>> end >>> end >> >> I do this all the time. But: >> >> class D < C ; end >> >> Always keep in mind that `D.var' will be something different >> than `C.var'. > > That's the point of attr_accessor: to give easy access to per-object > state. About a month ago I found myself doing even this: class C @x = "x-default" class <