I am looking for a concise way to match an AbstractArray
of T or Union{Nothing,T}
but not Nothing
. Does anyone have any ideas how to do that?
The general test I have been using is the following, with the ideal result being [true,true,false]:
julia> test_cases=[AbstractArray{Union{Nothing,Float64},<:Any},
AbstractArray{Float64,<:Any},
AbstractArray{Nothing,<:Any} ];
julia> typetest(T3)=((T1,T2)->T1<:T2).(test_cases,[T3]);
julia> typetest(AbstractArray{Union{Float64,Union{Nothing,Float64}},<:Any})
3-element BitArray{1}:
true
false
false
julia> typetest(AbstractArray{T,<:Any} where T<:Union{Float64,Union{Nothing,Float64}})
3-element BitArray{1}:
true
true
true
julia> typetest(AbstractArray{T,<:Any} where T<:Union{Nothing,Float64})
3-element BitArray{1}:
true
true
true
julia> typetest(Union{AbstractArray{Float64,<:},AbstractArray{Union{Nothing,Float64}},<:Any})
3-element BitArray{1}:
true
true
true
I think that the first case might be a bug, does anyone have any idea why it gives that result?