3 ms·
> Adding dedicated support for iterators would promote it as the way to iterate. That would actually simplify the language - one way to express a common need as
by ilyt 3y ago
> Adding dedicated support for iterators would promote it as the way to iterate. That would actually simplify the language - one way to express a common need as opposed to the current mess of ~5 different ways [1]:
There is one. Return a channel. Just a bit iffy when you want to stop iteration in the middle and throw away the rest.
- aziis98 3y agoReturning a channel is not really a cheap operation. They internally have locks that slow everything down as they are intended mostly as a safe concurrency primitive And in this case there is really no need to spawn goroutines to support iterators