Closed
Description
When using the for statement to loop over a slice, it is sometimes useful or necessary to take the address of each slice entry rather than a value copy. However, doing this is a bit inconvenient and could be made more readable.
Loop over a slice by value:
for _, v := range s {
...
}
Loop over a slice by address:
for i := range s {
p := &s[i]
...
}
Proposed syntactic extension to loop over a slice by address:
for _, p := &range s {
...
}
I believe the suggested extension is more readable and makes the intent clearer.