Skip to content

Commit 4de0733

Browse files
luiru72luiru72
authored andcommitted
Modified example according to code changes
1 parent c5f969a commit 4de0733

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

_tour/extractor-objects.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,18 @@ val CustomerID(name) = customer2ID
4545
println(name) // prints Nico
4646
```
4747

48-
This is equivalent to `val name = CustomerID.unapply(customer2ID).get`. If there is no match, a `scala.MatchError` is thrown:
48+
This is equivalent to `val name = CustomerID.unapply(customer2ID).get`.
4949

50-
```tut:fail
50+
```tut
5151
val CustomerID(name2) = "--asdfasdfasdf"
5252
```
5353

54+
If there is no match, a `scala.MatchError` is thrown:
55+
56+
```tut:fail
57+
val CustomerID(name3) = "-asdfasdfasdf"
58+
```
59+
5460
The return type of an `unapply` should be chosen as follows:
5561

5662
* If it is just a test, return a `Boolean`. For instance `case even()`.

0 commit comments

Comments
 (0)