go - What happens if I modify the slice I'm ranging over? -
go - What happens if I modify the slice I'm ranging over? -
i noticed had done this:
for t, ts := range timespans { // remove current item if t+1 < len(timespans) { timespans = append(timespans[:t], timespans[t+1:]...) } else { timespans = timespans[:t] } where
var timespans []timespan and
type timespan [2]time.time how range's work internally?
does work for i:=0; i<42; i++ loop (and skip items) or range on re-create of timespans, looked when loop first started, or else?
it works on re-create of slice, can modify slice's info in place ignore append , such.
go
Comments
Post a Comment