From: zdennis Date: 2006-04-08T02:19:37+09:00 Subject: Re: Simple Question About Deleting Instances Nathan Olberding wrote: > zdennis wrote: >> Can you post code along with your questions ? It makes it so much easier >> to help. > > class A > @@a = 1 > @b = 2 > def say_stuff() > puts @@a # Works > puts @b # Doesn't work > end > end You are creating an instance variable @b on your class A. The class A is an instance of the class Class, so it to can have instance variables. You want to define your instance variable @b inside of your initialize method, or you want to use attr_* methods to do this for you: class A @@a = 1 def initialize @b = 2 end def say_stuff puts @@a puts @b end end a = A.new a.say_stuff Or: class A attr_accessor :b @@a = 1 def initialize @b = 2 end def say_stuff puts @@a puts @b end end a = A.new a.b = 10 a.say_stuff You should really check this stuff out in IRB as well. Open a shell or cmd.exe and type 'irb'. Zach