Dictionaries.jl
Dictionaries.jl copied to clipboard
`in`/`∈` when item has a type that isn't a subtype of the `Indices` element type
julia> using Dictionaries
julia> Indices([1, 2, 3])
3-element Indices{Int64}
1
2
3
julia> 0 ∈ Indices([1, 2, 3])
false
julia> 1 ∈ Indices([1, 2, 3])
true
julia> "x" ∈ Indices([1, 2, 3])
ERROR: MethodError: Cannot `convert` an object of type String to an object of type Int64
Closest candidates are:
convert(::Type{T}, ::T) where T<:Number
@ Base number.jl:6
convert(::Type{T}, ::T) where T
@ Base Base.jl:84
convert(::Type{T}, ::Number) where T<:Number
@ Base number.jl:7
...
Stacktrace:
[1] in(i::String, indices::Indices{Int64})
@ Dictionaries ~/.julia/packages/Dictionaries/53DRB/src/AbstractIndices.jl:73
[2] top-level scope
@ REPL[11]:1
vs.
julia> Set([1, 2, 3])
Set{Int64} with 3 elements:
2
3
1
julia> 0 ∈ Set([1, 2, 3])
false
julia> 1 ∈ Set([1, 2, 3])
true
julia> "x" ∈ Set([1, 2, 3])
false
julia> import Pkg; Pkg.status("Dictionaries")
Status `...`
[85a47980] Dictionaries v0.4.1
Yes, I was a originally bit overzealous with convert, which should only really happen on insertion operations. We should fix this.