4 ms·
Not sure how I feel about this particular approach to iterators. I'd love for there to be some generate way to `range` over a generic collection, but idk about
by packetlost 3y ago
Not sure how I feel about this particular approach to iterators. I'd love for there to be some generate way to `range` over a generic collection, but idk about this.
- liquidgecka 3y agoHonestly I would just prefer an interface that can be implemented (not this interface.. one like it that is better thought out). type Iterator interface{} { // Returns the next object and true, or nil and false if iteration has ended. func NextIteration() (interface{}, bool) } Even better (in my opinion) if it also adds a finalizer function to help clean up resources used during iteration and some kind of error handling.. but that might be asking too much given my track record of getting golang improvements approved. I still want else on for statements dang it! =)