Hi, why Kotlin does not allow the use named arguments for function types?
m
martmists
05/14/2022, 10:24 AM
named parameters in function types are not enforced, but rather only used as hints for the IDE for what to name the parameters, and aren't guaranteed.
For example, the following would also be valid:
Copy code
fun myFunction(object: Any) {
// ...
}
// no parameter named `argument`, but it's fine since it matches the type used internally: `(Any) -> Unit`
Test(::myFunction)
j
Ji Sungbin
05/14/2022, 10:31 AM
I know that a named argument is not necessarily used for function use. As you said, omitting the named works just fine. However, I want to know why, although named arguments are allowed for general functions, they are not allowed for functional types.