4 ms·
Go has similar functionality: If you only need the second item in the range (the value), use the blank identifier, an underscore, to discard the first: sum :=
by sherwin 14y ago
Go has similar functionality:
If you only need the second item in the range (the value), use the blank identifier, an underscore, to discard the first:
sum := 0
for _, value := range array {
sum += value
}
from: http://golang.org/doc/effective_go.html#for http://golang.org/doc/effective_go.html#for