exercises: consider replacing some errors with optionals/asserts/assumes
@ee7 is already working on this.
Since Mar 12, 2023.
Assessment
This issue has not been assessed yet.
Description
For example, for binary-search, the Zig track currently requires the user to return an error when the input is empty:
or the value is not found:
But we can consider the empty array to be a normal case of "value not found", in which case the only possibilities are "value found, or value not found". Then we can return an optional. The Zig stdlib does that - the implementation of binarySearch returns ?usize
I'll propose changing this one. But we should look at all the exercises and think about whether it's better to return an optional, rather than an error union. Especially exercises where the error set is of length 1.
As of 2023-03-16, the exercises that can return a custom error are:
collatz-conjecturegrainshammingqueen-attacktriangle(considered in #257)
We previously had:
binary-search(removed in #259)rna-transcription(removed in #258)
I might propose removing more custom errors.
- Dominant language
- Zig
- Stars
- 73
- Forks
- 43
- Avg merge
- 6h 33m
- Merged PRs (30d)
- 12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from exercism/zig
-
Difficulty 1/5 Under an hour Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100