Usage of Array of abstract types in Julia
To expand upon the solution by @user3580870, you can also use a typealias
to make the function definition a little more succinct:
typealias RealArray{T<:Real} Array{T}
f(x::RealArray) = "do something with $x"
And then you can use the typealias in anonymous functions, too:
g = (x::RealArray) -> "something else with $x"
Since there's been an updated since the orginal answer, the keyword typealias
is gone so that the solution of @Matt B. would now be
const RealArray{T<:Real} = Array{T}
f(x::RealArray) = "do something with $x"
I'll just put this here for the sake of completeness ;)