#Modify new array of pointers without replacing pointers in another slice

5 messages · Page 1 of 1 (latest)

velvet adder
#

a=append(b, item) a might share the same array as b

#

i'm not sure where the problem is, i haven't open the gist.
but this line is shady
argRemainingTeams := append(remainingTeams[:i], remainingTeams[i+1:]...)

#

an example https://goplay.tools/snippet/Qli3LeV1hNt
~
i'm on my phone, looking at long codes on phone is painful.
try do

argRemainingTeams := append([]thetype(nil), remainingTeams[:i], remainingTeams[i+1:]...)

instead of

argRemainingTeams := append(remainingTeams[:i], remainingTeams[i+1:]...)
#

append create new slice, if its not big enough or nil.