-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend example code for "lexical closures" on 'Functions' page #5735
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
Comments
More generally, there might be room for a section on "how to declare parameters that are typed as functions", as it is not immediately clear how to do that. Here is some example code:
With the output:
|
atsansone
changed the title
[PAGE ISSUE]: 'Functions': Suggesting extended example code for "lexical closures"
Extend example code for "lexical closures" on 'Functions' page
Apr 23, 2024
atsansone
added
p2-medium
Necessary but not urgent concern. Resolve when possible.
e2-days
Can complete in < 5 days of normal, not dedicated, work
st.triage.ltw
Indicates Lead Tech Writer has triaged
a.language
Relates to the Dart language tour
labels
Apr 23, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
At
https://dart.dev/language/functions#lexical-closures
we are shown a code snippet showing a higher-order function creating an "adder function".
I feel as if the typing part is getting a bit of a short shrift as the higher-order function
makeAdder()
has return typeFunction
, which is a bit general. (I discovered it can be modified to returndynamic
with good results, or else to returnObject
but then I can't do anything with the object, but that's just by the by).Suggesting to show an alternate
makeAdder2()
which further specifies what is being returned. Like this: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: