Skip to content

Commit

Permalink
[kotlin/en] Parentheses can be omitted for single lambda args (#4708)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehaertl authored May 13, 2024
1 parent 094f083 commit ffe967e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kotlin.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ fun helloWorld(val name : String) {
// Named functions can be specified as arguments using the :: operator.
val notOdd = not(::odd)
val notEven = not(::even)
// Lambda expressions can be specified as arguments.
/*
Lambda expressions can be specified as arguments.
If it's the only argument parentheses can be omitted.
*/
val notZero = not {n -> n == 0}
/*
If a lambda has only one parameter
Expand Down

0 comments on commit ffe967e

Please sign in to comment.