I recently noticed that I 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 does range
's work internally?
Does it work like a for i:=0; i<42; i++
loop (and skip items) or does it range over a copy of timespans
, as it looked when the loop first started, or something else?