I don’t understand the following:
julia> String isa Type{String}
true
julia> ("abc", String) isa Tuple{String, Type{String}} # ?
false
julia> ("abc", String) isa Tuple{String, Type{T} where T}
true
julia> ("abc", String) isa Tuple{String, DataType}
true
The second one is the one I would like. I think 3d and 4th are equivalent. The slightly broader context is a data structure which contains maps of the type :abc => (value, typeof(value))
; I can type the dictionary
julia> Dict{Symbol, Tuple{T, DataType} where T}(
:abc => (2, Int),
:def => ("hello", String)
)
Dict{Symbol, Tuple{T, DataType} where T} with 2 entries:
:abc => (2, Int64)
:def => ("hello", String)
but not
julia> Dict{Symbol, Tuple{T, Type{T}} where T}(
:abc => (2, Int),
:def => ("hello", String)
)
ERROR: TypeError: in arrayset, expected Tuple{T, Type{T}} where T, got a value of type Tuple{Int64, DataType}
I can work around this / do this differently but I’m curious as to why this doesn’t work; is it the same as DataType with type parameter and the reference to the issue redesign typeof(::Type) · Issue #29368 · JuliaLang/julia · GitHub ?
Thanks