Re: [go-nuts] is this safe?

2017-11-21 Thread Jan Mercl
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

[go-nuts] is this safe?

2017-11-21 Thread DV
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

Re: [go-nuts] is this safe?

2017-11-20 Thread dwahler
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

Re: [go-nuts] is this safe?

2017-11-20 Thread Jan Mercl
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

[go-nuts] is this safe?

2017-11-20 Thread Trig
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