Dynamically Instantiating an Object
Ever wanted to write a method that instantiated an object of a class you specify? Below should be self-explanatory. Just call “const_get” method on the Object.
>> a = Object.const_get("String").new
=> ""
>> a.class
=> String
>> class Joon
>> def initialize
>> puts "Hello Joon"
>> end
>> end
=> nil
>> a = Object.const_get("Joon").new
Hello Joon
=> #
>>
