iterate method
Returns a lazy Iterable
by stepping through this range using by
.
The returned Iterable is lazy and potentially infinite.
final range = Interval.closedOpen(0, 5);
range.iterate(by: (e) => e + 1).toList(); // [0, 1, 2, 3, 4]
Implementation
@override
@useResult Iterable<T> iterate({required T Function(T current) by}) sync* {
for (var current = closed ? value : by(value); contains(current); current = by(current)) {
yield current;
}
}