https://kotlinlang.org logo
#coroutines
Title
# coroutines
m

miha-x64

02/27/2018, 8:36 PM
Is there a way to set a generic upper bound to
suspend Function<R>
? Exactly
Function
because I don't know yet how many arguments it will accept. Use-case: hierarchical web routing.
interface Address<T, HANDLER : suspend Function1<Unit>>
class Address1<T> : Address<T, suspend (T) -> Unit>
handles
/{a}/
addresses, fetches an object with
a
path, supplies fetched object to handler
class Address2<T, U> : Address<U, suspend (T, U) -> Unit>
handles
/{a}/{b}/
addresses, fetches
T
bound to
a
path, fetches its child
U
bound to
b
path, supplies them to handler and so on...
2 Views