Skip to content
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

filter not defined for enumerate #45337

Open
melonedo opened this issue May 17, 2022 · 2 comments
Open

filter not defined for enumerate #45337

melonedo opened this issue May 17, 2022 · 2 comments

Comments

@melonedo
Copy link
Contributor

MWE:

a = [1,2,3]
filter(isodd, a)
map(((x,i),)->isodd(x), enumerate(a))
# errors
filter(((x,i),)->isodd(x), enumerate(a))

The problem is that filter is not defined for Any.

@fonsp
Copy link
Member

fonsp commented May 17, 2022

Full error message on Julia 1.7:

julia> filter(((x,i),)->isodd(x), enumerate(a))
ERROR: MethodError: no method matching filter(::var"#3#4", ::Base.Iterators.Enumerate{Vector{Int64}})
Closest candidates are:
  filter(::Any, ::Tuple) at /Applications/Julia-1.7 x86.app/Contents/Resources/julia/share/julia/base/tuple.jl:363
  filter(::Any, ::Array{T, N}) where {T, N} at /Applications/Julia-1.7 x86.app/Contents/Resources/julia/share/julia/base/array.jl:2479
  filter(::Any, ::AbstractDict) at /Applications/Julia-1.7 x86.app/Contents/Resources/julia/share/julia/base/abstractdict.jl:431
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[13]:2

@mcabbott
Copy link
Contributor

Xref issue #37146 and PR #37195.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants