To clear doubts, is this:

class Foo
  @x = 50
  def self.x
    @x
  end
end

 the same than this?:

Foo.class_eval do
  @x = 50
  def self.x
    @x
  end
end

 I think yes. And is the first snippet the same than this?:

class Foo; @x = 50; end
Foo.instance_eval do
  def x
    @x
  end
end

 and than this?:

class Foo; @x = 50; end
class << Foo
  def x
    @x
  end
end

 and than this?, what you mean in the beginning of this topic:

class Foo
  @x = 50
  class << self
    def x
      @x
    end
  end
end

 Of course is better use attr_accessor but is just for understanding
purpose. This is a good topic, newbies will find this usefull.

-- 
Posted via http://www.ruby-forum.com/.