Add Optional.wherePresent helper to quiver.core
- Dominant language
- Dart
- Stars
- 1.1k
- Forks
- 133
- PR merge metrics
- No merged PRs in 30d
Description
Would it be possible to add a sensible way of unwrapping all the present values in an iterable of optional values? Basically the equivalent of `catMaybes` in Haskell's `Data.Maybe`
```
class Optional {
/**
* Returns an iterable containing the values of all the values of the optionals
* which are present in the argument.
*/
static Iterable wherePresent(Iterable optionals) =>
optionals.expand((opt) => opt.isPresent ? [opt.value] : []);
...
}
```
Contributor guide
Research direction
Start by locating the Optional class in quiver.core and inspect nearby iterable helpers and their tests. The work is done when Optional.wherePresent returns the values from present optionals while skipping absent ones, with coverage for the requested behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100