I ran into a problem with types today that I don't know how to interpret.
If I define a function according to
f(x::Real) = x
it returns x as expected as long as the type of x is a subtype of Real.
However if I define
f(x::Array{Real}) = x
it throws MethodError no matter what I pass as argument. For example when I
try to pass it an Int array:
f([1 2 3; 3 4 5])
ERROR: MethodError: `f` has no method matching f(::Array{Int64,2})
I would expect it to work like
f{T<:Real}(x::Array{T}) = x
and accept any array of reals. Am I missing something?