Hi,
I try to understand the difference between 'class variables' and 'class
instance variables', following a post by Guy Decoux a few days ago.
class A
@x = 12 # (class instance) variable
def A.test
puts @x
end
def instance_method
puts @@x # does not work, I'm sad ;-)
end
end
A.new.instance_method
=> NameError: uninitialized class variable @@x in A
I understand that @@x refers only to a (non existant) class variable of A. I
don't catch why there is a distinction between a class instance variable and
a class variable: the two are "stored" in the unique object representing the
class A, no ?
Is there a way to access the x variable from an instance of A ?
Francois