Overloaded function

How to overload a function in Base function. For instance, how should I do the following:

function abs(A::Array{Int64,2})
return abs.(A)
end

Error message:

error in method definition: function Base.abs must be explicitly imported to be extended
.
Stacktrace:
[1] top-level scope at none:0
[2] top-level scope at In[13]:1
[3] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091

I should mention that in the specific case, this probably isn’t an overload you should define. That said, all you need to do to do this is import Base.abs before defining the method.

1 Like

Thank you very much!