FAQ
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

       https://play.golang.org/p/m1Dc2YZDpZ

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
explicit.

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 @
categoriesgo
postedJan 13, '15 at 7:05p
activeJan 13, '15 at 8:34p
posts2
users2
websitegolang.org

2 users in discussion

Dave Cheney: 1 post Nicolas riesch: 1 post

People

Translate

site design / logo © 2021 Grokbase