Skip to content

Commit fc8b56e

Browse files
authored
Update Lambda args without braces docs (#16030)
At least on the latest nightly (Scala 3.2.2-RC1-bin-20220910-ac6cd1c-NIGHTLY), the example without colons doesn't seem to work. Also, the `foldLeft` call seems to be missing the initial value.
2 parents 7d322ce + 9df7a00 commit fc8b56e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/_docs/reference/experimental/fewer-braces.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ val firstLine = files.get(fileName).fold:
5252
5353
Braces can also be omitted around multiple line function value arguments:
5454
```scala
55-
val xs = elems.map x =>
55+
val xs = List.range(1, 10).map: x =>
5656
val y = x - 1
5757
y * y
58-
xs.foldLeft (x, y) =>
59-
x + y
58+
xs.foldLeft(0): (x, y) =>
59+
x + y * 8
6060
```
6161
Braces can be omitted if the lambda starts with a parameter list and `=>` or `=>?` at the end of one line and it has an indented body on the following lines.
6262

0 commit comments

Comments
 (0)