Skip to content

Commit 3432dbf

Browse files
authored
Merge pull request #15208 from ShapelessCat/fix-a-code-example-in-doc-pattern-matching
Fix a code example in the doc pattern-matching.md
2 parents c5710d0 + c1f1833 commit 3432dbf

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: "Option-less pattern matching"
44
movedTo: https://docs.scala-lang.org/scala3/reference/changed-features/pattern-matching.html
55
---
66

7-
The implementation of pattern matching in Scala 3 was greatly simplified compared to Scala 2. From a user perspective, this means that Scala 3 generated patterns are a *lot* easier to debug, as variables all show up in debug modes and positions are correctly preserved.
7+
The implementation of pattern matching in Scala 3 was greatly simplified compared to Scala 2. From a user perspective, this means that Scala 3 generated patterns are a _lot_ easier to debug, as variables all show up in debug modes and positions are correctly preserved.
88

99
Scala 3 supports a superset of Scala 2 [extractors](https://www.scala-lang.org/files/archive/spec/2.13/08-pattern-matching.html#extractor-patterns).
1010

@@ -180,7 +180,6 @@ object ProdEmpty:
180180
case _ => ()
181181
```
182182

183-
184183
## Sequence Match
185184

186185
- `U <: X`, `T2` and `T3` conform to `T1`
@@ -221,18 +220,18 @@ object CharList:
221220
the type of the remaining patterns are determined as in Seq Pattern.
222221

223222
```Scala
224-
class Foo(val name: String, val children: Int *)
223+
class Foo(val name: String, val children: Int*)
225224
object Foo:
226225
def unapplySeq(f: Foo): Option[(String, Seq[Int])] =
227226
Some((f.name, f.children))
228227

229228
def foo(f: Foo) = f match
230-
case Foo(name, ns : _*) =>
231-
case Foo(name, x, y, ns : _*) =>
229+
case Foo(name, x, y, ns*) => ">= two children."
230+
case Foo(name, ns*) => => "< two children."
232231
```
233232

234-
There are plans for further simplification, in particular to factor out *product
235-
match* and *name-based match* into a single type of extractor.
233+
There are plans for further simplification, in particular to factor out _product match_
234+
and _name-based match_ into a single type of extractor.
236235

237236
## Type testing
238237

0 commit comments

Comments
 (0)