tags:

views:

43

answers:

1

In the following fragment, is it possible to refer to the FOO constant from outside the module, and if so, how?

module X
  class << self
    FOO = 2
  end
end
+6  A: 
class <<X
  self
end::FOO

or

class Object
  def metaclass
    class <<self
      self
    end
  end
end

X.metaclass::FOO
sepp2k
There's no built-in method to get the metaclass? I guess the conclusion is that putting constants within the `class <<self` block is usually misguided.
Michiel de Mare