Make [Iterable|Stream].expand argument optional #8738
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
core-n
P2
A bug or feature request we're likely to work on
type-enhancement
A request for a change that isn't a bug
This issue was originally filed by @seaneagan
It would be nice if [Iterable|Stream].expand's argument were an optional positional and defaulted to:
(x) => x is Iterable ? x : [x]
It could alternatively be recursive:
(x) => x is Iterable ? x.expand() : [x]
... but that could lead to cycles, and a more generic way to recursively walk an Iterable might be better:
void walk(f) => forEach((x) => x is Iterable ? x.walk(f) : f(x));
then you could just do:
var flattened = [];
iterable.walk(flattened.add);
The text was updated successfully, but these errors were encountered: