Multiple dispatch with Union of parametric types

  1. Vector is an alias for Array{T, 1}, so it doesn’t matter how you write it.
  2. Union{Any, Vector{T}} is Any, so you lost Vector specialization.

This is working

function x(a::Array{T,N}, b::Dict) where {T,N}
    throw(DomainError("Do not support any arrays!"))
end

function x(a, b::Dict)
    return 1
end

function x(a::Vector{T}, b::Dict) where T
    return 1
end

julia> x([d1,d2], d3)
1
2 Likes