For loop giving "no method matching iterate" error

Hi,
I have some scripts that I would like to debug (using Atom + Juno).

If my understanding of the Julia debugger mechanics is correct, I have to wrap the code in a function in order to be able to call it, so I wrapped the main script code in a function and I’m calling that function from the REPL with Juno.@enter Main.mainFunction().

It seems that the debugger is working, more or less. I can do step-by-step debugging and see variables values. Unfortunately I’m still not able to place breakpoints, but I have to solve another problem before that…

I’m getting this weird error on a nested for loop that works correctly if the code isn’t wrapped:

    for req=1:numRequests
        log("blah")
        for report_root_node_id in nodeID_array
            log("yada")
        end
    end

and the error I get is:

ERROR: LoadError: MethodError: no method matching iterate(::Type{Array{String,1}})
Closest candidates are:
  iterate(::Core.SimpleVector) at essentials.jl:568
  iterate(::Core.SimpleVector, ::Any) at essentials.jl:568
  iterate(::ExponentialBackOff) at error.jl:199
  ...
Stacktrace:
 [1] mainFunction() at D:\Julia_Code\Main.jl:49
 [2] top-level scope at none:0
in expression starting at D:\Julia_Code\Main.jl:65

The outer for works flawlessly, but the inner one raises that strange error. Am I missing something?

Thanks!

You’ve probably done something like this:

nodeID_array = Vector{String}

when you meant to do

nodeID_array = Vector{String}()

The former makes nodeID_array’s value the type Vector{String} not an instance of that type, whereas the latter makes it an empty value of that type.

3 Likes