[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Easy question

Carl Youngblood

10/23/2003 4:35:00 AM

If I have a string that holds the name of a class that I want to
instantiate, do I use eval to do that, or is there some better way?

Thanks,
Carl Youngblood

1 Answer

gabriele renzi

10/23/2003 8:23:00 AM

0

il Thu, 23 Oct 2003 04:35:10 GMT, Carl Youngblood <carl@ycs.biz> ha
scritto::

>If I have a string that holds the name of a class that I want to
>instantiate, do I use eval to do that, or is there some better way?

a Better way:
>> class C ;end
=> nil
>> Object::const_get('C')
=> C