Implementing ArrayEachLimited method.
I'm not sure of the name, but just wrote implementation of ArrayEach with ability to stop processing array when required value found. To keep the backward compatibility I create new method ArrayEachLimited and ArrayEach uses it internally.
So callback function receives one extra argument – index of element in array and should return bool. If called callback returns false, ArrayEachLimited will stop processing.
What do you think?
In my opinion, it should return an error instead, and that error should be passed through to the caller of ArrayEachLimited.
I thought about error, but in my opinion, error need to return when something went wrong. In this case we just want to tell that no need to iterate more.
True, but error is more versatile. You could return io.EOF to signal "done iterating, no problem" to your outer code.
Sounds good. Waiting for Leonid vote
So, Leonid, what do you think about it?
I think I would prefer to return error, with io.EOF being a clean signal to stop.
Currently you can early exit in ObjectEach and I think adding that ability to ArrayEach would also be a good idea. Has there been any progress to resolve the branch conflicts? Are we still waiting @buger to vote?