Skip to content

Commit 41c3551

Browse files
committed
Fix typo
1 parent d982cd3 commit 41c3551

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ From Scala 3.1 on, type checking rules will be tightened so that errors are repo
1212

1313
```scala
1414
val xs: List[Any] = List(1, 2, 3)
15-
val (x: String) :: _ xs // error: pattern's type String is more specialized
15+
val (x: String) :: _ = xs // error: pattern's type String is more specialized
1616
// than the right hand side expression's type Any
1717
```
1818
This code gives a compile-time error in Scala 3.1 (and also in Scala 3.0 under the `-strict` setting) whereas it will fail at runtime with a `ClassCastException` in Scala 2. In Scala 3.1, a pattern binding is only allowed if the pattern is _irrefutable_, that is, if the right-hand side's type conforms to the pattern's type. For instance, the following is OK:

0 commit comments

Comments
 (0)