On 5/15/05, baalbek <rcs / bgoark.no> wrote: > In Java there is a construct like this: > > Class clazz = Class.forName("Person"); > > Person person = (Person)clazz.newInstance(); > > Is there something similar available for Ruby, that is, can I create a > class on the fly only having this class' name as a string? > > In other words, something like this (for Ruby): > > person = Class.new("Person") > > This does not work, but is there something that would work like this? Perhaps you want: Person = Class.new or Object.const_set "Person", Class.new Both will create a new class named "Person". The second method will let you use a name determined at runtime. If I understand your Java code above, the Ruby translation would be something like this: klass = Object.const_set("Person", Class.new) person = klass.new HTH, Mark