Artur Merke wrote: > Here comes some simple meta code > > >>>>>>>>>>>>>>>>>>>>>>>>> > class D > @@e=5 > @@f = 10 > @@g = 20 > class << self > attr_reader :e > attr_accessor :g > end > def self.f > @@f > end > > def show > print "\nshow @@e=",@@e, " @@f=", @@f, " @@g=",@@g > print "\nshow self.class.e=", self.class.e > print "\nshow self.class.f=", self.class.f > print "\nshow self.class.g=", self.class.g > end > end > > D.g= 40 > print "\nD.e= ",D.e > print "\nD.g= ",D.g > print "\nD.f= ",D.f > D.new.show > <<<<<<<<<<<<<<<<<<<<<<<<<<< > > here is the result > > D.e= nil > D.g= 40 > D.f= 10 > show @@e=5 @@f=10 @@g=20 > show self.class.e=nil > show self.class.f=10 > show self.class.g=40 > > I'would expect > D.e= 5 > D.g= 40 > D.f= 10 > show @@e=5 @@f=10 @@g=40 > show self.class.e=nil > show self.class.f=10 > show self.class.g=40 > > so what's wrong with my understanding, that > > class D > @@e=5 > class << self > attr_reader :e # <- why this does not refer to @@e > end > end sorry for the typo, I'would naturally expect D.e= 5 D.g= 40 D.f= 10 show @@e=5 @@f=10 @@g=40 show self.class.e=5 show self.class.f=10 show self.class.g=40