From: Robert Klemme Date: 2009-07-04T21:50:06+09:00 Subject: Re: How to remove/delete/destroy class variable in Ruby 1.9? On 04.07.2009 14:06, David A. Black wrote: > On Sat, 4 Jul 2009, dzw! wrote: > >> Ok, code below shows better what I am talking about, I understand that >> @@var is acting like global variable. >> But how to get rid of it when is not needed anymore? > You're trying to maintain and alter state on a per-class basis, which > really means on a per-object (class object) basis. Class variables are > not suited to that purpose; they are, as you say, really sort of > vertical globals. > > (In fact, I've always thought that $$var would be a better designation > for class variables than @@var, because @@var makes it look like class > variables have some kind of affinity with instance variables, which > they definitely don't.) The only commonality I can think of off the top of my head is the fact that you can use them from within instances much the same way as instance variables. > Anyway -- I don't know of any way to undefine a class variable. I'd > recommend using instance variables if you need per-class state. My 0.02 EUR: the best way to get rid of class variables is to not use them in the first place. :-) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/