They've had just a minute to marinate. In some parts of the community they're  unpopular. I don't particularly mind them. The old alternatives seem a

Go's New Iterators Smell (A Little) Funny, but It's Probably OK

submited by
Style Pass
2024-10-10 13:30:05

They've had just a minute to marinate. In some parts of the community they're unpopular. I don't particularly mind them. The old alternatives seem a little more "Go" to me, but the new iterators are largely fine.

I am mildly disappointed there isn't just a generic iterable type similar to the generic comparable — the imaginary iterable type being just a generic type that can accept maps, slices, arrays, and iterators. As I understand it, iterators combined with slices.All and maps.All are the blessed alternative to that. I'm not a huge fan, but it works well enough for those purposes.

The part that smells funny to me is that range now accepts any already existing function that happens to fulfill either of the following interfaces.

The first interface, known as Seq takes a yield method as an argument that itself accepts any single parameter. The second interface, known as Seq2 similarly takes a yield method that accepts any two parameters as essentially a key/value tuple.

Leave a Comment