Aren't we talking about standardizing iterators? That makes the compiler slightly more complex, I guess, but for the language it makes it much easier to read and more approachable imo. That's the reason that range exists in the first place.
I don't see why the author's implimentation is so complicated. I really just want an interface that works with the range operator, and to call it a day.
type Iterable[T any] interface {
Next() (T, bool)
}
so that
for _, el := range someIterable {
}
is essentially the same as
for el, ok := someIterable.Next(); ok; el, ok := someIterable.Next() {
}
I don't see why the author's implimentation is so complicated. I really just want an interface that works with the range operator, and to call it a day.
so that is essentially the same as I certainly think the first is more clear btw.