From: Phillip Gawlowski Date: 2010-01-09T04:25:41+09:00 Subject: Re: something strange with CLASS and SCOPE On 08.01.2010 19:57, Tony Tony wrote: > There is onething regarding class and scope I felt puzzled for a while. > Below is my code. > > > class QQ > @strange=Array.new > def report > puts @strange.class > end > end > > q=QQ.new > q.report > > From my understanding, instance variable should be available to every > method of a specific instance Only if your instance variables have been initialized, like so: class QQ def initialize # Used by Ruby when you do "QQ.new" @array = Array.new end def report puts @array.class end end q = QQ.new q.report (Actually, the class instance gets initialized, and not the instance variables, strictly speaking.) -- Phillip Gawlowski