Concerning "class instance variables"

H

Hal Fulton

Here's a slight reality check.

I'm probably largely responsible for the propagation of
the term "class instance variable." I didn't coin it, but
I used it in _The Ruby Way_.

It's not a totally bad term.

But let's remember that a class instance variable... is
really just an instance variable. It's just that the
object it belongs to happens to be a class.

This is confusing if you are used to languages such as
Java where classes aren't objects. In fact, when we say
that an instance variable "belongs to class Foo" in such
a language, we really mean that it belongs to _instances_
of class Foo.

In those languages, there is no distinction. In Ruby, there
is. A "class instance variable" is really just an instance
variable of a class, as opposed to an instance variable of
a non-class object.

In case that helps any.


Hal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,460
Latest member
eibafima

Latest Threads

Top