Skip to content

Instantly share code, notes, and snippets.

@dav1x
Created February 28, 2018 16:33
Show Gist options
  • Save dav1x/f0432e565a23e6a388dd2abbcb017aea to your computer and use it in GitHub Desktop.
Save dav1x/f0432e565a23e6a388dd2abbcb017aea to your computer and use it in GitHub Desktop.
Question 6:
Take a look at the following snippet of code.
package main
import "fmt"
type location struct {
longitude float64
latitude float64
}
func main() {
newYork := location{
latitude: 40.73,
longitude: -73.93,
}
newYork.changeLatitude()
fmt.Println(newYork)
}
func (lo *location) changeLatitude() {
(*lo).latitude = 41.0
}
In the 'changeLatitude' function, what is *location in the receiver list (after the word 'func') communicating to us?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment