Slackbot
05/27/2021, 8:21 PMNir
05/27/2021, 8:23 PM{}
outside of the parentheses of the call to someFunction
?Nir
05/27/2021, 8:36 PMNir
05/27/2021, 8:37 PMaction
) including call itNir
05/27/2021, 8:37 PMCasey Brooks
05/27/2021, 8:37 PMNir
05/27/2021, 8:38 PM{ }
part is the lambda function. Your follow up made it seem like you were more trying to understand someFunction
itself, which doesn't involve any lambdas.Casey Brooks
05/27/2021, 8:40 PMsomeFunction
is a “higher-order function”, since it operates on a “lambda”Nir
05/27/2021, 8:40 PMfun myAction(x: Int, y: Float): Unit {
println("first param = $x, second param = $y")
}
fun someFunction(
someParam: Int,
action: (someOtherParam: Int, lastParam: Float) -> Unit
) {
action(0, 9f)
}
fun main() {
someFunction(2, ::myAction)
}
Nir
05/27/2021, 8:40 PMNir
05/27/2021, 8:40 PMNir
05/27/2021, 8:51 PM