Flower Born wrote: >> >> The structure I observe with running the eval version is >> >> class Fil >> class NewClass1 >> end >> class NewClass2 >> end >> end > > > I tried both version all get the first result, I think this is a > reasonable > result(Ruby 1.8.6 on win32). Why do you think the result should be in > the > 2nd form? When I work with the following code - class Fil def self.add_class name #~ eval "#{name.capitalize} = Class.new(self)" #~ class_eval "#{name.capitalize} = Class.new(self)" end end Fil.add_class 'newclass1' Fil::Newclass1.add_class 'newclass2' #The test p Fil::Newclass2 == Fil::Newclass1::Newclass2 When I uncomment the eval (and comment the class_eval) the final line evaluates to true. When I uncomment the class_eval (and comment the eval) the final line throws an error - test.rb:12: uninitialized constant Fil::Newclass2 (NameError) It seems to me the behavior of the second test with class_eval and uninitialized constant is correct, but either way I'm most curious why they behave differently. I can't see how the scope of eval can be different than class_eval when the implicit receiver is self in both cases. -- Posted via http://www.ruby-forum.com/.