Skip to content

Commit 215e04a

Browse files
committed
Fix the view of match-syntax.md by adjusting the indentation of an ordered list
1 parent cee157e commit 215e04a

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

docs/docs/reference/changed-features/match-syntax.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,47 @@ title: Match Expressions
66
The syntactical precedence of match expressions has been changed.
77
`match` is still a keyword, but it is used like an alphabetical operator. This has several consequences:
88

9-
1. `match` expressions can be chained:
9+
1. `match` expressions can be chained:
10+
11+
```scala
12+
xs match {
13+
case Nil => "empty"
14+
case x :: xs1 => "nonempty"
15+
} match {
16+
case "empty" => 0
17+
case "nonempty" => 1
18+
}
19+
```
20+
21+
(or, dropping the optional braces)
22+
23+
```scala
24+
xs match
25+
case Nil => "empty"
26+
case x :: xs1 => "nonempty"
27+
match
28+
case "empty" => 0
29+
case "nonempty" => 1
30+
```
31+
32+
2. `match` may follow a period:
1033

1134
```scala
12-
xs match {
13-
case Nil => "empty"
14-
case x :: xs1 => "nonempty"
15-
} match {
16-
case "empty" => 0
17-
case "nonempty" => 1
18-
}
35+
if xs.match
36+
case Nil => false
37+
case _ => true
38+
then "nonempty"
39+
else "empty"
1940
```
2041

21-
(or, dropping the optional braces)
22-
23-
```scala
24-
xs match
25-
case Nil => "empty"
26-
case x :: xs1 => "nonempty"
27-
match
28-
case "empty" => 0
29-
case "nonempty" => 1
30-
```
31-
32-
2. `match` may follow a period:
33-
34-
```scala
35-
if xs.match
36-
case Nil => false
37-
case _ => true
38-
then "nonempty"
39-
else "empty"
40-
```
41-
42-
3. The scrutinee of a match expression must be an `InfixExpr`. Previously the scrutinee could be followed by a type ascription `: T`, but this is no longer supported. So `x : T match { ... }` now has to be
43-
written `(x: T) match { ... }`.
42+
3. The scrutinee of a match expression must be an `InfixExpr`. Previously the scrutinee could be
43+
followed by a type ascription `: T`, but this is no longer supported. So `x : T match { ... }`
44+
now has to be written `(x: T) match { ... }`.
4445

4546
## Syntax
4647

4748
The new syntax of match expressions is as follows.
49+
4850
```
4951
InfixExpr ::= ...
5052
| InfixExpr MatchClause

0 commit comments

Comments
 (0)