GarouDan
02/18/2019, 1:06 PMmethod_missing
of ruby, the __call__
in PHP, and so on.
I’ve heard about delegation in Kotlin, but I’m not so sure we can achieve the same result, for example, something like:
MyClass().unknownMethod()
// returns, for example, “You’ve called the `unknownMethod`“.
Can someone give me an small example how can we achieve that?
Thanks in advanceCzar
02/18/2019, 1:19 PMmurphy
02/18/2019, 1:24 PMmurphy
02/18/2019, 1:24 PMGarouDan
02/18/2019, 1:25 PMGarouDan
02/18/2019, 1:27 PMCzar
02/18/2019, 1:28 PMGarouDan
02/18/2019, 1:28 PMCzar
02/18/2019, 1:29 PMCzar
02/18/2019, 1:32 PM@Path("/api/.../{method}")
fun callAnyMethod(@PathParam("method") methodName: String) {
beanWithALotOfMethods
.methods
.findByName(methodName)
.invoke()
}
GarouDan
02/18/2019, 1:36 PM__noSuchMethod__
to handle this kind of things. The only problem is how can we tell the Kotlin compiler to use this method when the method is not a known one.
What do you guys think?reik.schatz
02/18/2019, 1:38 PMCzar
02/18/2019, 1:47 PMGarouDan
02/18/2019, 1:50 PMCzar
02/18/2019, 1:58 PM