How can this line in Java be translated to Ruby:
String className = "java.util.Vector";
...
Object o = Class.forName(className).newInstance();
Thanks!
Object::const_get('String').new()
If you're using ActiveSupport (i.e. Rails), there is a method added to String
that does this:
"String".constantize.new
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With