Skip to content

Instantly share code, notes, and snippets.

@orangy
Created May 6, 2014 20:05
Show Gist options
  • Save orangy/a67d0e21390a21838dc4 to your computer and use it in GitHub Desktop.
Save orangy/a67d0e21390a21838dc4 to your computer and use it in GitHub Desktop.
trait Injected<T> {
fun instance() : T
}
trait Imap {
class object : Injected<Imap> {
override fun instance(): Imap {
return ImapImpl()
}
}
fun auth() {}
}
class ImapImpl : Imap {}
fun routeHandler<T, TC : Injected<T>>(t : TC, body : (T)->Unit) {
body(t.instance())
}
val x = routeHandler(Imap) { imap ->
imap.auth()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment