On Tue, Nov 21, 2017 at 7:51 PM DV wrote:
> I think that's a horrible idea in any language, honestly. You shouldn't
be mutating the thing you're enumerating.
Go specs, for example, take care to guarantee it's safe in at least some,
if not all cases. Pruning eg. a map would otherwise incur a full
I think that's a horrible idea in any language, honestly. You shouldn't be
mutating the thing you're enumerating.
--
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
t
On Monday, November 20, 2017 at 11:32:34 AM UTC-6, Jan Mercl wrote:
>
> On Mon, Nov 20, 2017 at 5:48 PM Trig >
> wrote:
>
> > Is using append this way (to remove an index), inside of the range loop
> of the same array I'm working with, safe... since the size of myList is
> being changed within i
On Mon, Nov 20, 2017 at 5:48 PM Trig wrote:
> Is using append this way (to remove an index), inside of the range loop
of the same array I'm working with, safe... since the size of myList is
being changed within it?
It's safe as it will not crash your program. It's unsafe as it's a
quadratic algo
for i, user := range myList {
if user.Disabled {
myList = append(myList[:i], myList[i + 1:]...) // remove user from return
list
}
}
Is using append this way (to remove an index), inside of the range loop of
the same array I'm working with, safe... since the size of myList is being
chan