I copied the below code directly from the docs in Collections and Data Structures: Iteration.
next = iterate(iter)
while next !== nothing
(i, state) = next
# body
next = iterate(iter, state)
end
I defined iter as iter = 1:3
I’ve tried running it in its own file and in the REPL, and in both cases I get the following error:
ERROR: LoadError: UndefVarError: next not defined
I also tried using the global keyword to explicitly define next as a global variable, which didn’t resolve the issue. Is this a bug, or am I missing something?
This works for me as well. Do you have any idea why it’s the case that you are able to test the value of next before defining it, or why the code from the docs does not work?