u = [[1,1,1,1], [5,5]]
f(u::Vector{<:Number}) = println("here!")
f(u::Vector{Vector{<:Number}}) = println("there!")
Dispatching f() on a vector of numbers works.
f(u[1])
here!
Dispatching on a vector of vectors of numbers does not
f(u)
MethodError: no method matching f(::Array{Array{Int64,1},1})
Closest candidates are:
f(!Matched::Array{Array{#s1,1} where #s1<:Number,1})
f(!Matched::Array{#s1,1} where #s1<:Number)
although
Int64 <: Number
true
I went through the manual but the above behaviour remains unclear.
I thought f(u::Vector{Vector{<:Number}}) would be short-form notation for f(u::Vector{Vector{T}}) where {T<:Number}.
The latter long-form notation works as expected.
Could this be considered a bug in the way the short-form is lowered?
It was a conscious decision by @stevengj. Vector{Vector{<:Number}} is equivalent to Vector{Vector{T} where T<:Number}. The rationale is probably somewhere in: