If AnInterface
is Java, you can work with SAM conversion:
val impl = AnInterface { inst, num ->
//...
}
Otherwise, if the interface is Kotlin...
interface AnInterface {
fun doSmth(inst: MyClass, num: Int)
}
...you can use the object
syntax for implementing it anonymously:
val impl = object : AnInterface {
override fun doSmth(inst:, num: Int) {
//...
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…