Reputation: 15
I try convert to Kotlin.
But responseBody is Type mismatch.
handleHeavyContent(
event.replyToken,
event.message.id
) {responseBody ->
}
Required: Consumer
Found: (???) -> Unit
Upvotes: 0
Views: 66
Reputation: 2485
Example fun with Unit and lamba use:
fun x(
val a: Int,
val b: (param: Int) -> Unit
) {
// any code
b.invoke(a)
}
x(1) { param ->
println(param) // -> gives 1
}
Your function, after refactoring, must be missing parameter for lamba
Upvotes: 0
Reputation: 1453
Hey I had the same problem so after some searches finally I came up with some ways to define a lambda in a function. In your case I would do something like this
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)
}
Hope this helps you
Upvotes: 0