You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alternatively, it can be enabled with command line option `-language:experimental.fewerBraces`.
14
14
15
-
This variant is more contentious and less stable than the rest of the significant indentation scheme. It allows to replace a function argument in braces by a `:` at the end of a line and indented code, similar to the convention for class bodies. It also allows to leave out braces around arguments that are multi-line function values.
15
+
This variant is more contentious and less stable than the rest of the significant indentation scheme. It allows to replace a function argument in braces by a `:` at the end of a line and indented code, similar to the convention for class bodies. The `:` can
16
+
optionally be followed by the parameter part of a function literal.
16
17
17
18
## Using `:` At End Of Line
18
19
@@ -50,34 +51,31 @@ val firstLine = files.get(fileName).fold:
50
51
51
52
## Lambda Arguments Without Braces
52
53
53
-
Braces can also be omitted around multiple line function value arguments:
54
+
The `:` can optionally be followed by the parameter part of a function literal:
54
55
```scala
55
-
val xs = elems.map x =>
56
+
val xs = elems.map: x =>
56
57
val y = x - 1
57
58
y * y
58
59
xs.foldLeft (x, y) =>
59
60
x + y
60
61
```
61
-
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.
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
65
63
66
## Syntax Changes
64
67
68
+
As a lexical change, a `:` at the end of a line is now always treated as a
0 commit comments