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
Copy file name to clipboardExpand all lines: docs/_docs/reference/other-new-features/indentation.md
-59Lines changed: 0 additions & 59 deletions
Original file line number
Diff line number
Diff line change
@@ -502,62 +502,3 @@ indented regions where possible. When invoked with options `-rewrite -no-indent`
502
502
The `-indent` option only works on [new-style syntax](./control-syntax.md). So to go from old-style syntax to new-style indented code one has to invoke the compiler twice, first with options `-rewrite -new-syntax`, then again with options
503
503
`-rewrite -indent`. To go in the opposite direction, from indented code to old-style syntax, it's `-rewrite -no-indent`, followed by `-rewrite -old-syntax`.
504
504
505
-
###Variant:IndentationMarker `:` forArguments
506
-
507
-
Generally, the possible indentation regions coincide with those regions where braces `{...}` are also legal, no matter whether the braces enclose an expression or a set of definitions. There is one exception, though: Arguments to functions can be enclosed in braces but they cannot be simply indented instead. Making indentation always significant for function arguments would be too restrictive and fragile.
508
-
509
-
To allow such arguments to be written without braces, a variant of the indentation scheme is implemented under language import
510
-
```scala
511
-
importlanguage.experimental.fewerBraces
512
-
```
513
-
Inthis variant, a `<colon>` token is also recognized where function argument would be expected. Examples:
514
-
515
-
```scala
516
-
times(10):
517
-
println("ah")
518
-
println("ha")
519
-
```
520
-
521
-
or
522
-
523
-
```scala
524
-
credentials `++`:
525
-
valfile=Path.userHome /".credentials"
526
-
if file.exists
527
-
thenSeq(Credentials(file))
528
-
elseSeq()
529
-
```
530
-
531
-
or
532
-
533
-
```scala
534
-
xs.map:
535
-
x =>
536
-
valy= x -1
537
-
y * y
538
-
```
539
-
What's more, a `:` in these settings can also be followed on the same line by the parameter part and arrow of a lambda. So the last example could be compressed to this:
540
-
541
-
```scala
542
-
xs.map: x =>
543
-
valy= x -1
544
-
y * y
545
-
```
546
-
and the following would also be legal:
547
-
```scala
548
-
xs.foldLeft(0): (x, y) =>
549
-
x + y
550
-
```
551
-
552
-
The grammar changes forthis variant are asfollows.
0 commit comments