Short-hand for defining methods


Is there a way to define something like f(a::AbstractArray, b::AbstractArray, ...) without having to repeat the type each time?
I know I could do f(a::T, b::T, ...) where T <: AbstractArray but that would restrict all the arguments to be of the same type.


f(a,b,...). As an added bonus you get duck typing for free.


You could do something like

const AA = AbstractArray
f(a::AA, b::AA) = a .+ b


let T = AbstractArray
    global f(a::T, b::T) = a .+ b


Thanks for the suggestions. @ChrisRackauckas’ is very insightful :stuck_out_tongue: I was thinking more of a metaprogramming way, which I don’t know much about.