I know it is easy to remove an element in slice using:
   x = append(x[:n], x[n+1:]...)

But when slices contain pointers, I often forget to set the last element to
nil, which causes it not to be garbage collected.
So I must add this line to clear the last element:
   x[:n+1][n] = nil


But it is too easy to forget it.
Would a new "remove" builtin useful for this operation ?
Thus, the decision about setting the last element to nil would be more

Any opinion ?

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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
groupgolang-nuts @
postedJan 13, '15 at 7:05p
activeJan 13, '15 at 8:34p

2 users in discussion

Dave Cheney: 1 post Nicolas riesch: 1 post



site design / logo © 2021 Grokbase