-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HasNext() advances iterators position #46
Comments
Hmm, do you mind to check it with v1? Just remove v2 from the import. It looks like a regression, I can't check it right now but I will do it when I have access to my computer. |
@MadsRC Thanks for catching this! You’re right: The code works fine if you use it like this:
But relying on that behavior isn’t clean, and I also added tests to make sure this won’t break again. Appreciate the detailed report! Let me know if you hit anything else. |
@plar thank you, that was a quick turnaround ;) |
Writing integration testing for a code-base that uses this wonderful project, I ran across behavior that runs counter to what the documentation says. I am unsure if this is "working as intended" (in which case the docs most likely wrong) or if it is bug.
The documentation for the
Iterator
interfaces clearly states that callingNext()
advances the iterators position. While theHasNext()
documentation states that one should be careful to callHasNext()
before callingNext()
, I would still argue that the wording of the docs forNext()
indicates that one should not expectHasNext()
to advance the position of the iterator - otherwise you'd advance the iterator twice when callingHasNext()
followed byNext()
.The following piece of code reproduces the issue:
The output of the above is
date
.Furthermore, calling
Next()
does not seem to actually advance the pointer as evident by the following piece of code:The output of this block is:
The text was updated successfully, but these errors were encountered: