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

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -