Skip to content
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

tour: less confusing example in basics/7 #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

crisman
Copy link
Contributor

@crisman crisman commented Feb 26, 2023

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

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
@gopherbot
Copy link
Contributor

This PR (HEAD: 6dadc6d) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/website/+/471398 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants