by stevebmark · 1y ago · 0 comments
Agreed. Functions shouldn’t be full of short non-descriptly named variables.
The longer the lifetime/scope of a variable, and the more variables there are, the more descriptive the names should be.
for i := range personlist {
person := personlist[i]
...
}
Is more readable than for personNum := range personlist {
person := personlist[personNum]
...
}
because it makes clear that the i is basically irrelevant. The latter isn't bad style if you're three loops deep, because i, j, k is a bit harder to keep track of which is which.