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.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e5aeb96b-1d79-4258-ad60-e557f76dbaaeo%40googlegroups.com.

Reply via email to