How to create classes automatically

hi

let’s say I have a string with a class name as a value.
I want to create a new instance of the class with the given class name.

example:
when I have a string like this:

str = “Array”

I want to create a new Array class base on the information in str.

any ideas how this could be done ?

thanks a lot

Markus

Object.const_get(“Array”).new

On 8/3/06, [email protected] [email protected] wrote:

I want to create a new Array class base on the information in str.
any ideas how this could be done ?

str = “Array”
Object.const_get(str).new

thank you very much.

Markus

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs