|
|
|
|
|
by skldj28d2
728 days ago
|
|
Basically every custom data structure right now has some custom implementation of iterators. This will set a standard and make them usable with range loops. Even simple library methods like scanner.Scan, strings.Split, regex.FindAll or sql.Query should return iterators. |
|
But they already do, slices are iterables, and the input is bounded. Plus you have lots of other benefits like indexability. What need would it solve?
> scanner.Scan, sql.Query
Right, these are not suitable for slices because they’re unbounded. But still, what’s the use case? You still have roughly the same amount of code, no? Even the same noisy if err != nil checks. Can you provide a snippet that highlights the benefits?