From ad6e1f09bcb1aae8272bc296742c63d40eb9ff64 Mon Sep 17 00:00:00 2001 From: Risun <79560036+Risuntsy@users.noreply.github.com> Date: Tue, 23 Jul 2024 15:55:15 +0800 Subject: [kotlin/en] lambda functions wrong defined (#5007) lambda functions can not defined by `fun` directly, use `val` (or `var` if mutability is required) instead --- kotlin.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin.html.markdown b/kotlin.html.markdown index c16b5db1..45decb1e 100644 --- a/kotlin.html.markdown +++ b/kotlin.html.markdown @@ -124,7 +124,7 @@ fun helloWorld(val name : String) { You can also use lambda functions, with the '->' operator seperating the parameters from the function body. */ - fun fooLambda: (Int) -> Int = {n -> n + 1} + val fooLambda: (Int) -> Int = {n -> n + 1} println(fooLambda(1)) // => 2 // Functions can take functions as arguments and return functions. -- cgit v1.2.3