Suggest adding main() code to exercise example code for the generators on the 'Functions' page #5729
Labels
a.language
Relates to the Dart language tour
e2-days
Can complete in < 5 days of normal, not dedicated, work
from.page-issue
Reported in a reader-filed concern
p2-medium
Necessary but not urgent concern. Resolve when possible.
st.triage.ltw
Indicates Lead Tech Writer has triaged
Page URL
https://dart.dev/language/functions/
Page source
https://github.com/dart-lang/site-www/tree/main/src/content/language/functions.md
Describe the problem
The explainer for Generators at
https://dart.dev/language/functions#generators
shows ways to create generator
Iterable
-s or generatorStream
-s, but does not give example code for using them.This may be too verbose for the page, but I suggest just adding a
main()
to exercise the example code, which is particularly interesting for the case of using a Stream:For the "synchronous generator function":
which outputs
For the "asynchronous generator function":
which outputs
For the
yield*
generator function (what does it do? tail call optimization?)which outputs
Expected fix
No response
Additional context
No response
I would like to fix this problem.
The text was updated successfully, but these errors were encountered: