tour: less confusing example in basics/7 #199
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The code example in basics/7 (named-results.go) is confusing on many levels. The return values are not descriptive, thus offer no understanding of what function does. The paramater name (sum) seems to imply some prerequisite sum of values that is not defined nor explained anywhere. The math for 17 * 4 / 9 = 7 because of int truncation is confusing to some and not relavant to what the slide is trying to explain.
Provide descriptive names for parameters that match expected input (a number) and return value names that should be helpful in understanding what the function does. Change the function body to return the same values for the example input as the old code, but hopefully be a more understandable process.
Add a couple comments to directly explain that the named return values are already defined at the top of the function as well as what will be returned by the naked return.
Fixes golang/tour#730
Fixes golang/tour#840
Fixes golang/tour#777
Fixes golang/tour#489