Exercise-Errors

command
v0.0.0-...-93ce742 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

README

Copy your Sqrt function from the earlier exercise and modify it to return an error value.

Sqrt should return a non-nil error value when given a negative number, as it doesn't support complex numbers.

Create a new type

type ErrNegativeSqrt float64 and make it an error by giving it a

func (e ErrNegativeSqrt) Error() string method such that ErrNegativeSqrt(-2).Error() returns "cannot Sqrt negative number: -2".

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL