Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dict.update works with a Result #208

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/BasicDict/BasicDict.roc
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ expect

# We need to account for the case when a key (=fruit) is not in the Dict.
# So we need a function like this:
addFruit : [Present U64, Missing] -> [Present U64, Missing]
addFruit : Result U64 [Missing] -> Result U64 [Missing]
addFruit = \valueTag ->
when valueTag is
# If the fruit is not in the dict (=missing), we set the count to 1
Missing -> Present 1
Err Missing -> Ok 1
# If the fruit is in the dict (=present), we increase the count
Present count -> Present (count + 1)
Ok count -> Ok (count + 1)

Dict.get updatedDict "Apple" == (Ok 4)

Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading