Earlier quoted context omitted.
What is wrong with: for { next := getNext() ... } What is the advantage of writing this as: for next := range getNext { ... }
In practice the difference would be closer to: getNext := iterableThing.Iterator() for { next, ok := getNext() if !ok { break } ... } vs. for next := range iterableThing.Iterator() { ... } One advantage is that it's slightly shorter, which matters for very common patterns--people complain about `err != nil` after all. Another advantage is there isn't another variable for everyone to name differently. Another advantag…
getNext := iterableThing.Iterator()
for next, ok := getNext(); ok; next, ok = getNext() {
...
}
Which, yeah, the range cleans it up a bit, but it's not doing quite as much work as you're implying.