Correct type in function for Dict of NTuple

more generally, with various length tuples of elements of type T

dict3 = Dict( (1,2) => 2.0,  (1,2,3) => 3.0 )

accept(x) = false
accept(d::Dict{T, Float64}) where {T<:NTuple} = true

accept(dict3) == true

if you prefer the more specific

 julia> function fn(d:: Dict{NTuple{N,Int}, Float64}) where N
     return d
 end

julia> dict1 = Dict((1,2)=>2.0);
julia> dict2 = Dict((1,2,3)=>2.0);

julia> fn(dict1)
Dict{Tuple{Int64, Int64}, Float64} with 1 entry:
  (1, 2) => 2.0

julia> fn(dict2)
Dict{Tuple{Int64, Int64, Int64}, Float64} with 1 entry:
  (1, 2, 3) => 2.0
1 Like