Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Make Optional implement Iterable #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Andersmholmgren
Copy link

Implementing Iterable allows an Optionals to be passed into anything expecting an Iterable and facilitates common cases like

final optionals = <Optional<int>>[
        new Optional<int>.of(1),
        const Optional.absent(),
        new Optional<int>.of(2)
      ];
final ints = optionals.expand((i) => i); // (1, 2)

Note: this PR is a dupe of google/quiver-dart#289. No idea where PRs should be filed now. Confusing

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants