I have quite a few functions that I fix some of the arguments like partial application before injecting the new function into some other function. I’d like to be able to call the resulting function using named arguments.
The following works
fun add(a: Int, b: Int): Int {
return a + b;
}
fun createIncrementer(a: Int): (Int) -> Int {
return fun (b: Int): Int {
return add(a = a, b = b);
}
}
val plusOne = createIncrementer(a = 1);
Log.d("asdf", "add(a = 1, b = 2) returns " + add(a = 1, b = 2));
Log.d("asdf", "plusOne(2) returns " + plusOne(2));
But for better readability, I’d like to be able to write
Log.d("asdf", "plusOne(b = 2) returns " + plusOne(b = 2));
I see the following at https://jetbrains.github.io/kotlin-spec/#_misc
TODO: named arguments are not allowed for function types (both in () and .invoke() invocations)
Does this mean named arguments are coming or is this a note to document that they are not coming?
Thanks!