We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 097c4f9 commit 4ca8db0Copy full SHA for 4ca8db0
_overviews/scala3-book/types-union.md
@@ -21,8 +21,8 @@ case class Password(hash: Hash)
21
22
def help(id: Username | Password) =
23
val user = id match
24
- case Username(name) => lookupName(name)
25
- case Password(hash) => lookupPassword(hash)
+ case Username => lookupName(id)
+ case Password => lookupPassword(id)
26
// more code here ...
27
```
28
We implement the method `help` by distinguishing between the two alternatives using pattern matching.
0 commit comments