So, what’s the rationale for the following behaviour, which caught me by surprise:
julia> Union{Tuple{Int}, Tuple{Char}} <: Tuple
true
So, what’s the rationale for the following behaviour, which caught me by surprise:
julia> Union{Tuple{Int}, Tuple{Char}} <: Tuple
true
Any instance of Union{Tuple{Int}, Tuple{Char}}
is also an instance of Tuple
. A simpler example is
julia> Union{Int32,Int64} <: Integer
true
But the title of your question says isa
, which isn’t true:
julia> Union{Tuple{Int}, Tuple{Char}} isa Tuple
false
if everything in a Union <: T
, then this Union <: T
, after all, a Union is nothing but a “union” of types; Union should not be thought of as a type like Tuple or Set or Vector, similar to how DataType
shouldn’t be thought as “ordinary” types like Float64
or Integer
(thus the special behavior)
Yes, of course. Many thanks.