From: Gregory Brown Date: 2006-10-19T15:30:55+09:00 Subject: Re: metaprogramming surprise? On 10/18/06, gwtmp01@mac.com wrote: > > On Oct 17, 2006, at 2:02 PM, John W. Long wrote: > > > Jan Svitok wrote: > >> There's a difference between class variables (@@x) and singleton > >> class > >> instance variables (self.class.@x). They are not the same thing. > > Class variables seem to trip up everyone learning Ruby, yet > proficient Ruby programmers rarely seem to use them. Are they really > worth the trouble? I've yet to feel the need to use them but maybe > that is just me. Yeah, I use class instance variables all the time but it's rare for me to need a class variable. If i want to share something with my descendants, it's not often that I want that information to change, so a class level method or constant usually does the trick for me. Still, i imagine that there exist needs for them in some way or another. I remember using them in a few places, though I can't remember for what. ;) As mentioned earlier in the thread, If we treat instance variables as instance variables no matter where we define them, but just pay attention to how they are accessed, I think it gets much less confusing. I don't think i've ever used a global variable in Ruby aside from the builtins, but it doesn't necessarily mean they need to go away :)