I want the Crystal equivalent of this:
clazz = 'ExampleClass'.constantize # Rails
clazz = Object.const_get('ExampleClass') # pure Ruby
obj = clazz.new
You can't, these kind of dynamic aspects are not possible in Crystal.
However, macros can take a long way. Please read this similar issue and discussion:
https://github.com/manastech/crystal/issues/949
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