제너레이터 (Generators)
Iterable<int> naturalsTo(int n) sync* {
int k = 0;
while (k < n)
yield k++;
}Stream<int> asynchronousNaturalsTo(int n) async* {
int k = 0;
while (k < n)
yield k++;
}Iterable<int> naturalsDownFrom(int n) sync* {
if (n > 0) {
yield n;
yield* naturalsDownFrom(n - 1);
}
}문서 변경 이력
Last updated