For example there is the possibility in groovy to execute a method using following code:
@Test
void shouldAccessMethodDynamically() {
DynamicClass dynamic = new DynamicClass()
String name = 'dynamicMethod'
assert dynamic."$name"() == "dynamic"
assert dynamic."dynamicMethod"() == "dynamic"
}
Is this also possible in Kotlin?
You can call a method by name using regular java reflection API:
If you like to do it in more "kotlin way", you can use it like: