From: zdennis Date: 2006-04-08T02:45:23+09:00 Subject: Re: Simple Question About Deleting Instances Nathan Olberding wrote: > zdennis wrote: >> 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. > > Not to be a whiner, but is there a reason we can't just do attr_accessor > :@@var? What you're saying is logical, but it seems like we're getting > from point A to point B via point F. No. You just need to understand how classes and instances of a class work. attr_* methods set instance variables and get/set methods on an instance of a class. It does this using symbols. class A attr_accessor :b end :b will point to instance variable @b, on an instance of A. If you want to use attr_* to set class variables you need to work on the instance of the class itself. That is why we do: class A class << self attr_accessor :class_var end end Because "class << self" opens up the instance of class A. And :class_var will map to a '@class_var' instance variable on your class itself (and not on an instance of your class). If you want further shortcuts check out the facets or traits libraries on rubyforge. They may have what you are looking for, although I would ask you to understand how ruby works first before trying to shortcut this. Zach