I have created an interface:
interface ProgressListener {
fun transferred(bytesUploaded: Long)
}
but can use it only as an anonymous class, not lambda
dataManager.createAndSubmitSendIt(title, message,
object : ProgressListener {
override fun transferred(bytesUploaded: Long) {
System.out.println(bytesUploaded.toString())
}
})
I think it should be a possibility to replace it by lambda:
dataManager.createAndSubmitSendIt(title, message, {System.out.println(it.toString())})
But I am getting error: Type mismatch; required - ProgressListener, found - () -> Unit?
What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…