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

    :Array.to_s
     => "Array"

Regards,

Brian.