>>>>> "M" == MikkelFJ  <mikkelfj-anti-spam / bigfoot.com> writes:

M> (Elaborate on this example) -  instance variables in << Thing doesn't appear
M> to be globally shared nor avaible to Thing methods. (But then I'm currently
M> running 1.6.6 and 1.6.8 is changed I hear).

 If you want to make reference to [ruby-talk:47388] more precisely to this,
 be carefull

matz> Class variables belong to the innermost *non singleton* class.
matz> (the behavior has changed in 1.6.8 and later;  this is new one).

 If I'm right when matz make reference to "class variables", he make
 reference to @@var

 For example

pigeon% cat b.rb
#!/usr/bin/ruby
class A
   class << self
      @@a = 12
   end
   p @@a
end
pigeon% 

 with 1.6.7 the class variable is defined in the singleton class

pigeon% /usr/bin/ruby -v b.rb
ruby 1.6.7 (2002-03-01) [i686-linux]
b.rb:4: warning: declaring singleton class variable
b.rb:6: uninitialized class variable @@a in A (NameError)
pigeon% 

 with 1.7.2 the class variable is defined in the innermost *non singleton*
 class. in my example in A

pigeon% ./ruby -v b.rb
ruby 1.7.2 (2002-08-06) [i686-linux]
12
pigeon% 



Guy Decoux