Felix McCoey wrote:
> i know that in PHP it is possible to do the following:
> 
> $class_name = 'User';
> $$class_name->new()
> 
> but I want to do this in ruby like this perhaps:
> 
> @class_name = 'User'
> @class_name.new
> 
> What is this called and is it possible in ruby. Or is there an
> alternative to creating objects from just the class name?

You can always use const_get:

   class_name = 'User'
   klass = Object.const_get(class_name)
   obj = klass.new


Hope this helps...


Hal