Skip to content

Commit

Permalink
fixes quii#301
Browse files Browse the repository at this point in the history
  • Loading branch information
quii committed Jan 30, 2020
1 parent a8c8a66 commit 528fe9f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pointers-and-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func (w *Wallet) Balance() int {
and seemingly addressed the object directly. In fact, the code above using `(*w)` is absolutely valid. However, the makers of Go deemed this notation cumbersome, so the language permits us to write `w.balance`, without explicit dereference.
These pointers to structs even have an own name: _struct pointers_ and they are [automatically dereferenced](https://golang.org/ref/spec#Method_values).

Technically you do not need to change `Balance` to use a pointer receiver as taking a copy of the balance is fine. However by convention you should keep your method receiver types to be the same for consistency.

## Refactor

Expand Down

0 comments on commit 528fe9f

Please sign in to comment.