From: Cristian Szegedy Date: 2002-05-11T20:04:33+09:00 Subject: Class variable weirdness Recently I had some problemin one of my Ruby scripts. I could reduce it to the following excerpt. I don't whether it is a bug or a feature, but I don't really undestand it: # --------------------------------- class A @@x = 1 def A.f puts @@x @@x = 2 puts @@x end end class << A def g puts @@x @@x = 3 puts @@x end end A.f A.g # --------------------------------- I would have guessed that it outputs 1 2 2 3 In fact the result is : 1 2 2 2 I don't understand the behaviour of A.g: either it should not be able to read @@x, or it should be able to write it, or at least it should issue some warning. My Ruby is: ruby 1.6.7 (2002-03-01) [i686-linux] Thanks in advance, Christian