From: Eric Mahurin Date: 2005-07-04T01:32:39+09:00 Subject: Re: class variable leading a double life --- Devin Mullins wrote: > Thanks for the example. I'm just wondering why > > class Foo > def blah > @@cnt += 1 > end > end > > couldn't have been a shortcut for [an optimization of]: > > class Foo > class << self > attr_accessor :cnt > end > def blah > self.class.cnt += 1 > end > end I agree. Class variables should just be a shortcut for instance variables of an object's class. Having an independent and slightly different class variable concept seems redundant, confusing, and inconsistent. You could just say that these should be equivalent: @@x # self.class.instance_eval{@x} @@x = y # self.class.instance_eval{@x=y} __________________________________ Discover Yahoo! Stay in touch with email, IM, photo sharing and more. Check it out! http://discover.yahoo.com/stayintouch.html