However, you can define

f{T<:Union(Int64, Float64)}(v::Vector{T}) = v

to cover that case with a single method definition.

On Thursday, April 2, 2015 at 3:28:34 PM UTC-5, Michael Francis wrote:
>
> Thanks, that is what I suspected. 
>
> On Thursday, April 2, 2015 at 4:13:31 PM UTC-4, Mauro wrote:
>>
>> Types in Julia are invariant: 
>>
>> If T1<:T2 is true 
>> then A1{T1}<:A1{T2} is false (unless T1==T2). 
>>
>> Now setting T1=Float64 and T2=Union( Int64, Float64) means 
>> Vector{Float64}<:Vector{Union( Int64, Float64)} is false.  Thus the no 
>> method error. 
>>
>> On Thu, 2015-04-02 at 21:32, Michael Francis <[email protected]> wrote: 
>> > Is the following expected behavior for union types, I'm assuming yes ? 
>> > 
>> > v = Union( Int64,Float64 )[] 
>> > push!( v, 1.2) 
>> > push!( v, 1)   # works 
>> > 
>> > f( v::Union(Int64,Float64)...) = v 
>> > f( [ 1.2 ]...) # Works 
>> > 
>> > f( v::Vector{Union( Int64, Float64)}) = v 
>> > f( [ 1.2 ])    # 'f' has not method matching f(::Array{Float64,1}) 
>> > 
>> > At first glance I'd expect the last case to work as well. 
>>
>>

Reply via email to