Ruckus
08/22/2018, 4:40 PMFunctionX
.
I have a use case where I need a "recursive" function type, so I can't use a typealias:
typealias Interceptor<T, U> = (Store<T, U>, U, Interceptor<T, U>) -> Unit // Cannot be done
I can define a specific interface to replace that like so:
interface Interceptor<T, U> : (Store<T, U>, U, Interceptor<T, U>) -> Unit
but that interface cannot be used as a lambda:
fun <T, U> test(interceptor: Interceptor<T, U>) { ... }
// You have to do this
test(object: Interceptor<String, Int> {
override fun invoke(store: Store<String, Int>, value: Int, interceptor: Interceptor<String, Int> {
...
}
})
// I would like to do this
test<String, Int> { store, value, interceptor -> ... }
Ilmir Usmanov [JB]
08/22/2018, 4:51 PMRuckus
08/22/2018, 4:54 PMRuckus
08/22/2018, 5:00 PMFunction
.uli
08/22/2018, 7:30 PM