Help decoding this deprecation

Sorry, IMO, another complicate it evolution example.
How do I write the new correct form?

julia> contains(==, fieldnames(GMT.GMTgrid), Symbol("z"))
┌ Warning: `contains(eq::Function, itr, x)` is deprecated, use `any((y->begin
│             eq(y, x)
│         end), itr)` instead.
│   caller = top-level scope
└ @ Core :0
true

julia> any((y->begin == end), fieldnames(GMT.GMTgrid), Symbol("z"))
ERROR: MethodError: no method matching start(::Symbol)
Closest candidates are:
  start(::SimpleVector) at essentials.jl:550
  start(::Base.MethodList) at reflection.jl:659
  start(::ExponentialBackOff) at error.jl:171
  ...
Stacktrace:
 [1] reduced_indices(::Tuple{Base.OneTo{Int64}}, ::Symbol) at .\reducedim.jl:35
 [2] reduced_indices at .\reducedim.jl:6 [inlined]
 [3] reducedim_initarray at .\reducedim.jl:79 [inlined]
 [4] reducedim_initarray at .\reducedim.jl:80 [inlined]
 [5] reducedim_init at .\reducedim.jl:133 [inlined]
 [6] mapreducedim at .\reducedim.jl:272 [inlined]
 [7] any(::Function, ::Array{Symbol,1}, ::Symbol) at .\reducedim.jl:612
 [8] top-level scope
julia> struct Foo
           a
           z
       end

julia> any(equalto(:z), fieldnames(Foo))
true

julia> any(equalto(:b), fieldnames(Foo))
false
1 Like

Thanks, though that is not what the deprecation message points as to.

It is basically telling you to use:

julia> any(y -> y == :z, fieldnames(Foo))
true

Slightly off-topic: an interesting possibility is this PR who would allow to create these currified functions with underscores, so this would become:

julia> any(_ == :z, fieldnames(Foo))
true

which IMO is more elegant than a specialized currified version equalto

From what I understood, this didn’t make it for Julia 0.7 but will be part of a future release.

1 Like