Task

Invoke an object method where the name of the method to be invoked can be generated at run time.



Related tasks

 Respond to an unknown method call.
 Runtime evaluation


import "meta" for Meta
 
class Test {
    construct new() {}
 
    foo() { System.print("Foo called.") }
 
    bar() { System.print("Bar called.") }
}
 
var test = Test.new()
for (method in ["foo", "bar"]) {
    Meta.eval("test.%(method)()")
}