Hi --

On Sat, 6 Jan 2007, Brock Lee wrote:

> So, would it be fair to say that you won't run into difficulties with
> class variables (denoted with @@) if:
>
>    a. you assign class variables in the superclass before assigning
> them in the sublcass, and

Assuming you understand that when you assign them in the subclass,
you're assigning to the exact same variable, throughout the hierarchy.

>    b. you don't expect class_eval to provide access to them?
>
> Or are there other areas of confusion?

The most important lesson to learn about class variables, I believe,
is that they have *nothing* to do with instance variables.  They're
not a replacement for them; they're not the equivalent for classes
(instance variables exist for classes); and the @/@@ thing is purely
cosmetic.

The reason I say this is that most of the confusion I've seen over the
years has to do with class variables getting in the way of
understanding instance variables, since they lead people to assume
that the idea of a class having an instance variable is meaningless
(since there are already class variables...).  That, in turn, makes it
much harder to understand instance variables.


David

-- 
Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    (See what readers are saying!  http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)