Gyuhyeon
02/17/2020, 9:17 AM.filter{req: ClientRequest, next: ExchangeFunction ->
// do something
}
works.
However, what I'd like to do is pass a function reference instead of the lambda so that I don't have to actually put 50 lines of code inside the .filter
call.
I'm quite new to Kotlin and I have a very fragile understanding of higher order functions, so I have no idea how to achieve this.
I thought making the method like this -
private fun customFilter(request: ClientRequest, next: ExchangeFunction){
}
and calling like .filter(::customFilter)
would work, but it didn't - IDE tells me
Type mismatch.
Required:
ExchangeFilterFunction
Found:
KFunction2<@ParameterName ClientRequest, @ParameterName ExchangeFunction, Unit>
It seems like I have to somehow implement the ExchangeFilterFunction.java which is a java @FunctionalInterface
...? Any advice is appreciatedGabriel Shanahan
02/17/2020, 12:54 PMval x = ClientRequest(...)
.filter(x::customFilter)
Gabriel Shanahan
02/17/2020, 12:55 PM