Skip to content

Commit 0c772e2

Browse files
committed
Fix doc page layout
1 parent 0bc44b0 commit 0c772e2

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

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

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,41 @@ 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:
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:
9+
1. `match` expressions can be chained:
3310

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

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 { ... }`.
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 { ... }`.
4544

4645
## Syntax
4746

0 commit comments

Comments
 (0)