From: "Iñaki Baz Castillo" Date: 2009-12-19T11:13:54+09:00 Subject: Re: special cased? El Sábado, 19 de Diciembre de 2009, Roger Pack escribió: > This confused me a bit > > class A > @a = 2 > @@a = 3 > def self.a > puts [@a, @@a] > end > end > > class B < A; end > > A.a # [2, 3] > B.a # [nil, 3] > > shouldn't @a just lookup @@a in the parent? Different treatment for > different types of variables? When you write: class A @a = 2 take into account that @a=2 is just parsed when loading class A for first time. When you later do "class B < A; end", the Ruby interpreter doesn't read the line "@a = 2" again as it already parsed class A and just stored in memory the methods of class A. -- Iñaki Baz Castillo