google / google/quiver-dart

Add Optional.wherePresent helper to quiver.core

Open
#76 3 comments 0 reactions 0 assignees View on GitHub
enhancement
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.