From: Xavier Noria Date: 2006-11-17T18:48:07+09:00 Subject: Re: newbie question about attr_reader On Nov 16, 2006, at 1:01 PM, dblack@wobblini.net wrote: > class C > class << self > attr_accessor :x > end > end > > Now, the class object C has an attribute "x": > > C.x = 1 > puts C.new.class.x # 1 David, technically is there any relationship between the attribute @x here class A @x = 1 end and the @x that accessor deals with? That would be an attribute of what? Is there a singleton instance of the singleton class? Or is that @x an attribute of A as instance of Class? I tried to get this right with examples but I guess the exact answer comes from the actual implementation. -- fxn fxn@feynman:~/tmp$ cat foo.rb class A @x = 0 @y = 1 class << self def x @x end attr_accessor :y end end puts A.x, A.y fxn@feynman:~/tmp$ ruby foo.rb 0 1