Consider the following code:
julia> f1(x::NTuple{N,T}) where {N, T<:Number} = "ok"
f1 (generic function with 1 method)
julia> f1((1,2,3))
"ok"
However, when I specifying N
to be an integer as following:
julia> f2(x::NTuple{N,T}) where {N<:Integer, T<:Number} = "not work"
f2 (generic function with 1 method)
julia> f2((1,2,3))
ERROR: MethodError: no method matching f2(::Tuple{Int64,Int64,Int64})
Closest candidates are:
f2(::Tuple{Vararg{T<:Number,N<:Integer}}) where {N<:Integer, T<:Number} at REPL[3]:1
Stacktrace:
[1] top-level scope at none:0
Why would Tuple{Int64,Int64,Int64}
not match NTuple{N,T} where {N<:Integer, T<:Number}
here?