Re: [go-nuts] pointer receiver basic question

2020-07-23 Thread Ian Lance Taylor
On Thu, Jul 23, 2020 at 5:27 PM Robert Solomon wrote: > > Hi. I'm going thru the example code for container/heap. In the > documentation is this example: > > func (h *IntHeap) Pop() interface{} { > old := *h > n := len(old) > x := old[n-1] > *h = old[0 : n-1] // my question is about this line

[go-nuts] pointer receiver basic question

2020-07-23 Thread Robert Solomon
Hi. I'm going thru the example code for container/heap. In the documentation is this example: func (h *IntHeap) Pop() interface{} { old := *h n := len(old) x := old[n-1] *h = old[0 : n-1] // my question is about this line. return x } Why does the last assignment have to assign to a dereferen