Findfirst ERROR: MethodError: no method matching keys

I’m sure this is addressed somewhere, I just can’t (drum-roll) find it.

Given some matrix, I want to find the first row whose sum is odd:

julia> m = [0 0 0; 1 1 1; 2 2 2]
3×3 Array{Int64,2}:
 0  0  0
 1  1  1
 2  2  2

julia> map(isodd∘sum, eachrow(m))
3-element Array{Bool,1}:
 0
 1
 0

But this errors:

julia> findfirst(isodd∘sum, eachrow(m))
ERROR: MethodError: no method matching keys(::Base.Generator{Base.OneTo{Int64},Base.var"#174#175"{Array{Int64,2}}})
Closest candidates are:
  keys(::Core.SimpleVector) at essentials.jl:602
  keys(::Cmd) at process.jl:639
  keys(::LibGit2.GitTree) at /home/yakir/.julia/packages/Revise/S7mrl/src/git.jl:52
  ...
Stacktrace:
 [1] pairs(::Base.Generator{Base.OneTo{Int64},Base.var"#174#175"{Array{Int64,2}}}) at ./abstractdict.jl:132
 [2] findfirst(::Base.var"#56#57"{typeof(isodd),typeof(sum)}, ::Base.Generator{Base.OneTo{Int64},Base.var"#174#175"{Array{Int64,2}}}) at ./array.jl:1747
 [3] top-level scope at REPL[149]:1
1 Like

See keys(::Generator) for find* and arg* · Issue #34674 · JuliaLang/julia · GitHub, keys(::Generator) pass through by rapus95 · Pull Request #34678 · JuliaLang/julia · GitHub.

2 Likes