On 5/10/06, ts <decoux / moulon.inra.fr> wrote:
> >>>>> "R" == Raphael Bauduin <rblists / gmail.com> writes:
>
> R> method. The class variable @@v is also added to the same object
> R> specific class.
>
>  Are you sure ?
>
> moulon% ruby -e 'class << Object.new; @@a = 12 end; p @@a'
> -e:1: warning: class variable access from toplevel singleton method
> 12

I was not sure ;-)

In the mean time I read this very interesting article:
http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html

So methods are added to the object specific class (the metaclass as
identified in why's article), but class variables are added to the
class of which the object is an instance. Why the difference?

Further on this, if I defined a second instance and try to call test:
b=A.new(6)
b.test

I get the error that test is a private method:
NoMethodError: private method `test' called for #<A:0xb7cbf5ec @value=6>

so it seems it was added to A, but marked as private.

Are there any good reading about this?
Oh, and about my initial question: how bad is the warning I get?

Raph