Skip to content

Commit 4ca8db0

Browse files
authored
Update types-union.md
do we need parameters inside case statements?
1 parent 097c4f9 commit 4ca8db0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

_overviews/scala3-book/types-union.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ case class Password(hash: Hash)
2121

2222
def help(id: Username | Password) =
2323
val user = id match
24-
case Username(name) => lookupName(name)
25-
case Password(hash) => lookupPassword(hash)
24+
case Username => lookupName(id)
25+
case Password => lookupPassword(id)
2626
// more code here ...
2727
```
2828
We implement the method `help` by distinguishing between the two alternatives using pattern matching.

0 commit comments

Comments
 (0)