Skip to content

Commit ec5a391

Browse files
committed
Be clear about precedence
1 parent 1a26208 commit ec5a391

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

docs/docs/reference/changed-features/pattern-matching.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def unapply[A](x: T)(implicit x: B): U
1616
def unapplySeq[A](x: T)(implicit x: B): U
1717
```
1818

19-
Extractors expose the method `unapply` are called fix-arity extractors, which
19+
Extractors expose the method `unapply` are called fixed-arity extractors, which
2020
work with patterns of fixed arity. Extractors expose the method `unapplySeq` are
2121
called variadic extractors, which enables variadic patterns.
2222

@@ -44,9 +44,11 @@ type R = {
4444

4545
and `S` conforms to one of the following matches:
4646

47-
- Single match
48-
- Name-based match
47+
- single match
48+
- name-based match
4949

50+
The former form of `unapply` has higher precedence, and _single match_ has higher
51+
precedence over _name-based match_.
5052

5153
### Variadic Extractors
5254

@@ -58,8 +60,8 @@ def unapplySeq[A](x: T)(implicit x: B): U
5860

5961
The type `U` conforms to one of the following matches:
6062

61-
- Sequence match
62-
- Product-sequence match
63+
- sequence match
64+
- product-sequence match
6365

6466
Or `U` conforms to the type `R`:
6567

@@ -72,6 +74,9 @@ type R = {
7274

7375
and `S` conforms to one of the two matches above.
7476

77+
The former form of `unapplySeq` has higher priority, and _sequence match_ has higher
78+
precedence over _product-sequence match_.
79+
7580
## Boolean Match
7681

7782
- `U =:= Boolean`
@@ -169,7 +174,7 @@ object ProdEmpty {
169174
```
170175

171176

172-
## Seq Match
177+
## Sequence Match
173178

174179
- `U <: X`, `T2` and `T3` conform to `T1`
175180

@@ -201,7 +206,7 @@ object CharList {
201206
// e,x,a,m
202207
```
203208

204-
## Product-Seq Match
209+
## Product-Sequence Match
205210

206211
- `U <: Product`
207212
- `N > 0` is the maximum number of consecutive (parameterless `def` or `val`) `_1: P1` ... `_N: PN` members in `U`
@@ -221,5 +226,5 @@ def foo(f: Foo) = f match {
221226
}
222227
```
223228

224-
There are plans for further simplification, in particular to factor out *Product
225-
Pattern* and *Name Based Pattern* into a single type of extractor.
229+
There are plans for further simplification, in particular to factor out *product
230+
match* and *name-based match* into a single type of extractor.

0 commit comments

Comments
 (0)