Reputation: 185
Assuming I can construct a string that matches an existing class, how do I invoke it?
For example, I have several classes:
And I want to dynamically invoke each of them by constructing a string that matches their names. If they all had the method "methods", how do I do something like this?:
(1..3).each do |n|
("MyClass"+n).methods
end
Upvotes: 12
Views: 7668