我尝试转换为 Kotlin。
但是responseBody类型不匹配。
handleHeavyContent(
event.replyToken,
event.message.id
) {responseBody ->
}
必填: 消费者
找到:(???) -> 单位
最佳答案
嘿,我遇到了同样的问题,所以经过一番搜索后,我终于想出了一些在函数中定义 lambda 的方法。 在你的情况下我会做这样的事情
fun handleHeavyContent(
event.replyToken,
event.message.id,
response : (ResponseBody) -> Unit){
//do your code and get the response body and pass it to the variable
// get the body from a function or object and then use it like this
val body : ResponseBody //initialize it here
response(body)
}
希望这对你有帮助
关于java - 如何在 Kotlin 中使用 Lambda handleHeavyContent(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57389591/