在Julia中,我想将函数参数的类型指定为数组数组.所以我有
function foo{T <: Any}(x::Array{Array{T}})
Run Code Online (Sandbox Code Playgroud)
但是如果我x在REPL中设置参数,例如:
x = Array[[0,1],[1,2,3],[0,1,2,4]]
Run Code Online (Sandbox Code Playgroud)
然后它会自动获取以下类型赋值(例如),其中包括其尺寸:
x::Array{Array{T,N},1}
Run Code Online (Sandbox Code Playgroud)
所以我得到了错误
ERROR: `foo` has no method matching foo(::Array{Array{T,N},1}).
Run Code Online (Sandbox Code Playgroud)
我根本不想限制数组维度,因此我们认为解决方案可能就是这样
function foo{T <: Any, N <: Number}(x::Array{Array{T,N},N})
Run Code Online (Sandbox Code Playgroud)
但这也不起作用.
如何将参数类型指定为数组数组?