From: Xavier Shay Date: 2008-10-10T00:22:03+09:00 Subject: Enumerating constants in anonymous modules How can I enumerate all the constants inside the module in the second example? Notice that #constants array is empty For bonus points, which is the "correct" eval method to use to define a class inside the module (they all seem to work) Cheers, Xavier module Foo class A end end puts Foo.constants.inspect # => ["A"] [:module_eval, :instance_eval, :class_eval].each do |method| m = Module.new m.send(method) do class B end end puts m.constants.inspect # => [] (I would expect ['B']) puts m.const_get('B').inspect # => B end -- Posted via http://www.ruby-forum.com/.