From: "David A. Black" Date: 2009-07-05T09:07:38+09:00 Subject: Re: How to remove/delete/destroy class variable in Ruby 1.9? Hi -- On Sun, 5 Jul 2009, Bertram Scharpf wrote: > Hi, > > Am Samstag, 04. Jul 2009, 23:40:32 +0900 schrieb David A. Black: >> On Sat, 4 Jul 2009, Bertram Scharpf wrote: >> >>> class Object ; remove_class_variable "@@var" ; end >> >> I forgot all about that method. I guess I'm rusty on class variables, >> from lack of use :-) > > I don't use them either. Sometimes I wonder about that because > a "@@var" is much shorter than a "MyClass.var". It seems to be > more disturbing you than simplifying your code. I did some weird > things like these: > > class C ; end > C.class.instance_eval "@@x = 'X'" > class < > I gave up trying to understand it. > > The easiest thing is when accessors look the same in classes and > in instances: > > class MyClass > attr_accessor :iv # @iv in MyClass.new > class < attr_accessor :cv # @cv in MyClass > end > @cv = "initial" > end Yes; I definitely think it's a case where the "classes are objects too" thing makes it fall into place. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) Training! Intro to Ruby, with Black & Kastner, September 14-17 (More info: http://rubyurl.com/vmzN)