以下是从 Java 用 Kotlin 重写的方法:
fun publishMessageSource(
name: String,
address: String,
completionHandler: Handler<AsyncResult<Unit>>
) {
val record = MessageSource.createRecord(name, address)
publish(record, completionHandler)
}
但是,当我这样称呼它时:
publishMessageSource("market-data", ADDRESS, { record: Handler<AsyncResult<Unit>> ->
if (!record.succeeded()) {
record.cause().printStackTrace()
}
println("Market-Data service published : ${record.succeeded()}")
})
我得到错误Type Mismatch required Handler<AsyncResult<Unit>> found (Handler<AsyncResult<Unit>>) -> Unit
。
我究竟做错了什么?