Created
September 4, 2020 09:56
-
-
Save frencojobs/87ef24e150a5beb49b5bfa24a652c683 to your computer and use it in GitHub Desktop.
Me trying my best to explain yield* syntax of dart.
This file contains hidden or 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> inner() sync* { | |
for (final i in [4, 5, 6]) { | |
yield i; | |
} | |
} | |
Iterable<int> outer() sync* { | |
for (final i in [1, 2, 3]) { | |
yield i; | |
} | |
yield* inner(); | |
} | |
void main() { | |
for (final i in outer()) { | |
print(i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment