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: handle error rather than print both #218

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

Commits on Mar 20, 2023

  1. tour: handle error rather than print both

    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
    crisman committed Mar 20, 2023
    Configuration menu
    Copy the full SHA
    625960b View commit details
    Browse the repository at this point in the history