Last active
March 9, 2020 00:50
-
-
Save armando-couto/f25db0272994b247d869b804031154a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Iterable<int> countTo(int max) sync { | |
int i = 0; | |
while(i < max) yield i++; | |
} | |
main() { | |
Iterable it = countTo(5); | |
Iterable i = it.iterator; | |
while (i.moveNext()) { | |
print(i.current); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stream<int> countTo(int max) async* { | |
int i = 0; | |
while(i < max) yield i++; | |
} | |
main() async { | |
Stream s countTo(5); | |
await for (int i in s) { print(i); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment