From: ts Date: 2002-11-20T19:19:26+09:00 Subject: Re: Need help dynamically creating classes. >>>>> "P" == Paul Gregory writes: P> Brilliant, thanks, that is exactly what I needed. Well, I don't really know what you want to do, and I've tried to do what you want but personnally I'll write it like this pigeon% cat b.rb #!/usr/bin/ruby class SceneObject class << self attr_accessor :generate end def render instance_eval(&type.generate) end end def defineClass(name, &block) Object.const_set(name, Class.new(SceneObject)).generate = block end defineClass("MyObject") do puts "render some object #{self}" end a = MyObject.new a.render pigeon% pigeon% b.rb render some object # pigeon% I don't know why but it seems more natural, for me, to have a class instance variable rather than try to call #initialize Guy Decoux