# New method for 'Base.sum'

**URL:** <https://discourse.julialang.org/t/new-method-for-base-sum/108427>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 6, 2024, 7:21am UTC](https://discourse.julialang.org/t/new-method-for-base-sum/108427 "2024-01-06T07:21:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [January 6, 2024, 7:28am UTC](https://discourse.julialang.org/t/new-method-for-base-sum/108427/2 "2024-01-06T07:28:23Z")

</div>

Yes this is very common if one wants to extend a function to work with one’s own type. This avoids shadowing the function, we just had this discussion yesterday:

> [@Step!() remains strangely unfound if buried inside another method](https://discourse.julialang.org/t/step-remains-strangely-unfound-if-buried-inside-another-method/108316/4):
>
> As Steven said you are shadowing the function - think of it as overwriting the definition, so step! is not related to DynamicalSystems.step! at all. Here’s a simple example: julia\> struct A end julia\> sum(x::A) = 5 sum (generic function with 1 method) julia\> sum(A()) 5 julia\> sum([1,2,3]) ERROR: MethodError: no method matching sum(::Vector{Int64}) You may have intended to import Base.sum As you see, the sum I created there has only 1 method, so there is nothing for multiple dispatch to do.…

---

_[View the full topic](https://discourse.julialang.org/t/new-method-for-base-sum/108427)._
