Skip to content

Commit 82a7b00

Browse files
committed
Update doc page to allow inline lambdas
# Conflicts: # docs/_docs/reference/experimental/fewer-braces.md
1 parent 67be15a commit 82a7b00

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ val xs = elems.map: x =>
5959
xs.foldLeft (x, y) =>
6060
x + y
6161
```
62-
Braces can be omitted if the lambda starts with a parameter list and an arrow symbol `=>` or `?=>`.
63-
The arrow is followed on the next line(s) by the body of the functional literal which must be indented
64-
relative to the previous line.
62+
Braces can be omitted if the lambda starts with a parameter list and an arrow symbol `=>` or `?=>`. The arrow is followed by the body of the functional literal, which can be
63+
either on the same line or as an indented block on the following lines. Example:
64+
```scala
65+
val xs = elems
66+
.map: x => x * x
67+
.foldLeft (x, y) => x = y
68+
```
6569
6670
## Syntax Changes
6771
@@ -78,4 +82,8 @@ ColonArgument ::= indent CaseClauses | Block outdent
7882
| FunParams (‘=>’ | ‘?=>’) ColonArgBody
7983
| HkTypeParamClause ‘=>’ ColonArgBody
8084
ColonArgBody ::= indent (CaseClauses | Block) outdent
85+
| <silent-indent> (CaseClauses | Block) outdent --
8186
```
87+
The last line is understood as follows: If the token following a `=>` or `?=>` in a
88+
`ColonArgument` is not an `indent`, then the parser inserts a silent indent token
89+
and assumes the associated indentation region has maximal indentation width.

0 commit comments

Comments
 (0)