我创建了一个界面:
interface ProgressListener {
fun transferred(bytesUploaded: Long)
}
但只能用作匿名类,而不能用作 lambda
dataManager.createAndSubmitSendIt(title, message,
object : ProgressListener {
override fun transferred(bytesUploaded: Long) {
System.out.println(bytesUploaded.toString())
}
})
我认为应该有可能用 lambda 代替它:
dataManager.createAndSubmitSendIt(title, message, {System.out.println(it.toString())})
但是我得到了错误: Type mismatch; required - ProgressListener, found - () -> Unit?
我做错了什么?