From: Anders Borch Date: 2003-07-01T19:28:21+09:00 Subject: Re: dynamic object creation Brian Candler wrote: > On Tue, Jul 01, 2003 at 05:23:35AM +0900, Anders Borch wrote: > >>>A class name is just a constant, so something like >>> >>> a = Module.const_get("Array").new >> >>uhm... why does this work? >> >>I just tested it and to my surprise it worked?! >> >>http://rubycentral.com/book/ref_c_module.html#Module.const_get >> >>says that I need to supply a symbol, why does it accept a string? > > > Even if it didn't, you can easily convert strings to symbols and vice versa. > > "Array".intern > => :Array hadn't seen that one, thanks =) > :Array.to_s > => "Array" > > Regards, > > Brian. > -- dc -e 4dd*od3*dddn1-89danrn10-dan3+ann6*dan*2*an13dn1+dn2-dn3+5*ddan2/9+an13nap