Hi --

On Sun, 7 Oct 2007, Bertram Scharpf wrote:

> Hi,
>
> 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.


David

-- 
Upcoming training from Ruby Power and Light, LLC:
   * Intro to Ruby on Rails, Edison, NJ, October 23-26
   * Advancing with Rails, Edison, NJ, November 6-9
Both taught by David A. Black.
See http://www.rubypal.com for more info!