diff options
author | Risun <79560036+Risuntsy@users.noreply.github.com> | 2024-07-23 15:55:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-23 09:55:15 +0200 |
commit | ad6e1f09bcb1aae8272bc296742c63d40eb9ff64 (patch) | |
tree | 50145750513c0082678c4f6efa75ae1a4a35dce0 | |
parent | be1e100e38945418dfa1656741bccf9dc7674de9 (diff) |
lambda functions can not defined by `fun` directly, use `val` (or `var` if mutability is required) instead
-rw-r--r-- | kotlin.html.markdown | 2 |
1 files changed, 1 insertions, 1 deletions
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. |