From: Ryan Davis Date: 2011-03-14T06:13:15+09:00 Subject: Re: can someone explain this? On Mar 13, 2011, at 13:10 , Andy Bogdanov wrote: > # First I create a proc: > p = proc { > self::X = Class.new > def self.X > X.new > end > } > > # Then I create a module: > A = Module.new(&p) > puts A.X # => # > > # Then i create another module: > B = Module.new(&p) > puts B.X # => # > > # Everything seems to be ok. > > # And now to the strange part. > # After module B was created A.X started to return instances of B::X > puts A.X # => # > > If more modules are created with the same proc method X returns > instances of X from the last created module. If I use "self::X.new" > instead of "X.new" everything works as expected, but I can't understand > why it works like that with "X.new". Is this a bug or it's supposed to > be this way? I suggest you send that to ruby-core@