# Overloaded function

**URL:** <https://discourse.julialang.org/t/overloaded-function/48085>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 10, 2020, 1:53am UTC](https://discourse.julialang.org/t/overloaded-function/48085 "2020-10-10T01:53:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![F-YF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/f-yf/32/17363_2.png) [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Post date:** [October 10, 2020, 1:53am UTC](https://discourse.julialang.org/t/overloaded-function/48085/1 "2020-10-10T01:53:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [October 10, 2020, 1:57am UTC](https://discourse.julialang.org/t/overloaded-function/48085/2 "2020-10-10T01:57:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![F-YF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/f-yf/32/17363_2.png) [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Post date:** [October 10, 2020, 2:38am UTC](https://discourse.julialang.org/t/overloaded-function/48085/3 "2020-10-10T02:38:17Z")

</div>

Thank you very much!
