I have a Ruby program that generates files that contain a Module definition :
# try.rb
module Test
class F1
def initialize arg
@arg=arg
end
end
end
Now, I’d like the same program to create instances of F1.
What is the right idiom to do that ?
loadorrequirethe file:then you can use
Object.const_getto get a reference to the class object, and use that to create an instance: