In Kotlin, it is possible to give lambda arguments names in their definition.
fun example(lambda: (a: Int, b: Int) -> Int)
As you can see, a
and b
are named in the lambda. I thought this might be really useful information for an IDE, to generate lambdas with the parameter names filled-in.. but at least with IntelliJ the functionality either doesn't exist or works in a way I'm unaware.
So, what are the uses of named lambda arguments? Do they change the compile output in some way? And are there any tricks you can use them for?
Currently, no language feature uses these names, and, as far as I know, the only thing that does is the generation of lambda templates by the IDE plugin:
Then Tab or Enter, and you will get the lambda with the parameter names declared in the
example
definition:Also, see this issue: Make use of named higher order function parameters