From: Brian Candler Date: 2010-01-09T05:53:34+09:00 Subject: Re: something strange with CLASS and SCOPE Phillip Gawlowski wrote: > (Actually, the class instance gets initialized, and not the instance > variables, strictly speaking.) It's worth mentioning that a class is itself an object (an instance of class Class), and therefore has its own instance variables. class QQ # at this point, the current object ('self') is class QQ itself @strange=Array.new def report # but here, the current object is an instance of class QQ # so this is an instance variable in a different object puts @strange.class end end Sometimes the class itself is a useful place to store values: class QQ @count = 0 def self.count @count end def self.count=(x) @count = x end def initialize self.class.count = self.class.count + 1 end end a = QQ.new b = QQ.new puts "You have created #{QQ.count} QQ's" -- Posted via http://www.ruby-forum.com/.