Hi –
On Fri, 17 Aug 2007, Arno J. wrote:
@first_instance_var # self = A
All three variables are instance variables (just because of the @, as
far as I know).
BUT, for what I’ve read on the web / in books
first_… would be called a “class instance variable”
second_… would be called an “instance variable”
third_… would not be called (I never met any), or would be called a
“class instance variable” according to you, although self is not a class
but a singleton class.
Singleton classes are classes. More importantly, though, it’s best to
keep the terminology as simple as possible.
All of these things are instance variables. The only reason to use a
longer name is to make it clear in usage where someone might not know
what you mean. If you’ve got an instance variable of #Class:A, you
will almost certain describe as “an instance variable of the singleton
class of the class A”, or something like that. There’s almost
certainly no need to create a separate term for it.
Mind you, I don’t think I’ve ever seen such an instance variable, so
it’s probably not a big problem 
you’re talking about, but I don’t know how to build it 
You can always write a wrapper like this:
def self.x
@x
end
or you can write an x method in the class or singleton class of x.
Similarly for x= (the setter method).
You can also use the attr_* family of methods to create the wrapper
method(s) for you.
To do that in your example, you’d do:
class A
class << self
class << self
attr_accessor :x
end
end
end
But you’ll never see this much nesting!
A more common case might
be:
class A
end
a = A.new
class << a
attr_accessor :x
end
which creates attribute get/set methods for ‘x’ on the object a.
David