From: Ittay Dror Date: 2008-07-14T20:30:00+09:00 Subject: Re: Help with class instance variables Hi, David A. Black wrote: > Hi -- > > > The problem is that the instance variables you're initializing belong > to the singleton class of Platform (class << Platform), not Platform. > Compare with this: > > class C > class << self > attr_accessor :x > end > > @x = 1 # or self.x = 1 > end > > puts C.x # 1 > Ok, thank you, that cleared things. I have two follow up questions: 1. If I want to add an instance variable to an object of class C I can only do that in a method (not as part of the class definition)? In the example above, how can I change it so that C.new will return an instance of C where '@x' of the instance is 1? 2. Is there an analogous way to 'initialize' to write initialization of class variables? Thank you, Ittay > > David -- Posted via http://www.ruby-forum.com/.