A type question

Why this is false?

Dict{NTuple{4, Int}, Float64}() isa (Dict{NTuple{L, <:Integer}, <:Real} where L)
# returns false

Interestingly, this is true:

Dict{NTuple{4, Int}, Float64}() isa (Dict{NTuple{L, T}, <:Real} where {L, T<:Integer})
# returns true

The <: only goes out one level:

julia> (Dict{NTuple{L, <:Integer}, <:Real} where L) == Dict{NTuple{L, I} where I<:Integer, <:Real} where L
true

Thus, the first type on the RHS accepts dicts whose key type is literally NTuple{L, I} where I<:Integer (but not any subtype thereof because of default invariance) and whose element type is any subtype of Real.

1 Like