From: "Iñaki Baz Castillo" Date: 2009-12-20T04:53:01+09:00 Subject: Re: special cased? El Sábado, 19 de Diciembre de 2009, David A. Black escribió: > I think you mean shouldn't it just look up @a (not @@a) in the parent > -- and the answer is no :-) A and B are different objects, and > therefore do not share instance variables. class A @a = "hello" def self.say puts defined?(@a).inspect end end A.say => "instance-variable" nil class B < A ; end B.say nil nil But as I already explained, the line '@a = "hello"' is just parsed by Ruby interpreter when loading class A. When creating class B (which inherits from A) the Ruby parser doesn't read the whole class A definition again. Instead it already has in memory all the class/instance methods defined for class A so it wouldn't read '@a = "hello"' anymore. And because of it, B class object doesn't know @a as its instance variable, it knows nothing about @a. -- Iñaki Baz Castillo