From: "Jan E." Date: 2012-09-16T05:39:00+09:00 Subject: Re: Class variables or class singleton variables? I don't get what you mean. The singleton class of a class is obviously not the same as the class itself, so getting different object IDs was to be expected. Maybe you mean something different? If you wonder why I open the singleton class in the original class with "self" instead of outside the class with the name: That's both the same, but the first approach is less redundant and (in my opinion) more readable. But you should actually use "send". And again: You cannot define a class instance variable for Foo in the singleton class of Foo. Those are two different variables: class Foo @x = 'Foo' class << self # or class << Foo @x = 'singleton' end end [Foo, Foo.singleton_class].each do |c| puts "#{c}: @x == #{c.instance_variable_get :@x}" end An instance variable always belongs to a specific object instance (hence the name). So if you define @x within the body of the singleton class, it will actually belong to the singleton class and not the original class. -- Posted via http://www.ruby-forum.com/.