-
Notifications
You must be signed in to change notification settings - Fork 522
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: unclear instruction for errors exercise #273
Comments
Why? If you're printing the result of the call, you'll get two elements. |
Because expected output was not clearly defined and |
👍 was unclear to me also what the exercise was intending. Got there in the end, had to search internet (found this) when trying to More focus on the standard return pattern for errors in the previous step with a full working implementation would have been appreciated. |
In "tour/methods/20" ("Exercise: Errors") just after the slide explaining "calling code should handle errors by testing whether the error equals nil" the example code in the errors exercise provides a main that calls functions expecting error values and does not check them. Checking error values is the expected go way of doing things and should be shown. In the successful case it is also odd to show the "nil" of no error when printing the correct answer (see golang/tour#273). Printing the likely undefined float64 root value when there is an error is also confusing. Update "methods/exercise-errors.go" and matched solution to only print error on error and only root otherwise. Fixes golang/tour#273 Fixes golang/tour#230
Context: https://tour.golang.org/methods/20
The instruction does not clearly define what to do.
I was expecting an output:
while the only output I was able to produce is
as fmt.Println(Sqrt(2)) will print "error"
and fmt.Println(Sqrt(-2)) will print the float64 part
It should be also noted earlier that %g is the way to print float64
My code:
The text was updated successfully, but these errors were encountered: