expand<T> method
Expands each element of this Iterable into zero or more elements.
The resulting Iterable runs through the elements returned
by toElements
for each element of this, in iteration order.
The returned Iterable is lazy, and calls toElements
for each element
of this iterable every time the returned iterable is iterated.
Example:
Iterable<int> count(int n) sync* {
for (var i = 1; i <= n; i++) {
yield i;
}
}
var numbers = [1, 3, 0, 2];
print(numbers.expand(count)); // (1, 1, 2, 3, 1, 2)
Equivalent to:
Iterable<T> expand<T>(Iterable<T> toElements(E e)) sync* {
for (var value in this) {
yield* toElements(value);
}
}
Implementation
@override
Iterable<T> expand<T>(Iterable<T> Function(E element) f) =>
_values.expand<T>(f);