I'm trying to learn Julia by reading the documentation, and they have code that looks like this:
function testFunction(x::Number)
return x+5
end
This is a function that works for any of the many numeric types in Juila.
However, if I attempt to do something similar, like this:
function testFunction2(x::Array{Number})
return x
end
I get the following error:
ERROR: MethodError: no method matching testFunction2(::Array{Int64,1})
Closest candidates are:
testFunction2(::Array{Number,N} where N) at /Users/.../Desktop/Test.jl:45
Am I doing something wrong? I thought this: Array{Float64}
is how you declare an array of a specific type, yet using a type like Number
, which works for the regular case, doesn't work here... Any insight is appreciated.