3 ms·
Unrelated to your question, but your code doesn't traverse array. All it does is: for i := 0; i < len(ints); i++ { sum += i }
by dchest 14y ago
Unrelated to your question, but your code doesn't traverse array. All it does is:
for i := 0; i < len(ints); i++ {
sum += i
}
- lobster_johnson 14y agoSorry, that was a typo. The actual test program I use is correct. It was obviously supposed to be: sum += ints[i]
- Djehngo 14y agoNot relevant to the performance test but you can do this for index, value := range mySlice { } and you get the index and the value, or you can do for _, value := range mySlice { } If you only need the value.