Default value of parameter in function type


I try it and they give me a error, wy it is unsupported?

I do not want to pass error value every time that I call the callback.
Please explain-me. Tanks


(Boolean, String) -> Unit is the type of callback, so as it is not a function it cannot have default arguments.


Thanks for that. Can you give me some example in how can I have default arguments in that case?


Make a couple of functions that you can call in the implementations of register(...):

fun success(callback: (Boolean, String) -> Unit) {
    callback(true, "")

fun error(callback: (Boolean, String) -> Unit, message: String) {
    callback(false, message)

In the register(...) implementations you can then use either of these lines:

error(callback, "Error message")


Sounds good, thanks.