Usually when we define a high-order function, we never name the parameters for the lambda(s):
fun high(f: (Int, String) -> Unit) {
f(1, "Romeo")
}
high { q, w ->
//Do something
}
But it is possible to add them. So, the f lambda now has its parameters named—age and name:
fun high(f: (age:Int, name:String) -> Unit) {
f(1, "Romeo")
}
This doesn't change any behavior, it is just to give more clarity on the intended use of this lambda:
fun high(f: (age:Int, name:String) -> Unit) {
f(age = 3, name = "Luciana") //compilation error
}
But it isn't possible to call a lambda with named parameters. In our example, invoking f with names produces a compilation error.