From: Gary Wright Date: 2011-03-08T15:30:47+09:00 Subject: Re: basic programming question, help please On Mar 8, 2011, at 1:10 AM, Mayank Kohaley wrote: > On Tue, Mar 8, 2011 at 11:13 AM, Gary Wright wrote: >> >> If you think this is complicated and somewhat confusing you are right. Most >> programmers expect Ruby's class variables to behave like C++'s or Java's >> class variables but they are very different. >> > I am very new to Ruby and coming from C++ background, the class variables > act differently in Ruby vs C++ , Thanks for the explanation Gary I probably should have added that a 'class instance variable' in Ruby is analogous to a 'class variable' in C++ or Java. A 'class instance variable' is just a plain old instance variable for an object that happens to be a class. Unfortunately most Ruby books choose to spend more time talking about Ruby's 'class variables' rather than 'class instance variables' and fail to make it clear that Ruby's 'class variables' aren't at all like class variables in other languages. The fact that Ruby's instance variables and class variables have similar sigils just adds to the confusion ('@foo' vs. '@@foo'). Gary Wright