Let’s have 2 functions declaration
fun handle(param: Int, param2: Int, consumer: () -> Unit) {
consumer()
}
fun handle(param: Int, param2: Int, consumer: (param: Int, param2: Int) -> Unit) {
consumer(param, param2)
}
And let’s try to call function using lambdas
handle(1, 2) {
System.out.println("handle!")
}
Error, compiler can’t decide which function to call but it’s much more likely the first one, more - if I explicitly add empty arrow:
handle(1,2) { ->
System.out.println()
}
IDE will highlight that arrow as not needed.
So I propose to use function without parameters when there are no references to “it” receiver when this situation appears.