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 dereferenced pointer, ie, *h = old[0 : n-1]?
Why does it not work if the last assignment is written as old = old[0 : n-1]? I know this does not work because I tried it.
Thanks for your attention.