3 ms·
It's a slightly pedantic thing, but since the article is about the syntax of the loops, the author has misused the range loop in most cases. When you only prov
by codezero 13y ago
It's a slightly pedantic thing, but since the article is about the syntax of the loops, the author has misused the range loop in most cases.
When you only provide one variable for assignment, you are actually assigning the key (or incremental value), not the value, the syntax is:
for key, value: := range someThing {
When you do:
for something := range someThing {
something won't have the value. If you just want the value you need to use:
for _, value := range someThing {