# Overwriting Methods

**URL:** <https://discourse.julialang.org/t/overwriting-methods/17078>\
**Category:** General Usage\
**Created:** [November 2, 2018, 1:23am UTC](https://discourse.julialang.org/t/overwriting-methods/17078 "2018-11-02T01:23:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)\
**Post date:** [November 2, 2018, 1:23am UTC](https://discourse.julialang.org/t/overwriting-methods/17078/1 "2018-11-02T01:23:35Z")

</div>

Is there a way to tell when you are overwriting a method?

For example:  
The following code exists:

```julia
f(x::Int) = 0

```

And then this exists somewhere later:

```julia
f(x::Int) = 1

```

Is there a way to make the second line of code error?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [November 2, 2018, 1:25am UTC](https://discourse.julialang.org/t/overwriting-methods/17078/2 "2018-11-02T01:25:37Z")

</div>

You can start with `--warn-overwrite` but I don’t think there is a way right now to make it error

```julia
$ julia --warn-overwrite=yes -q
julia> f(x::Int) = 0
f (generic function with 1 method)

julia> f(x::Int) = 1
WARNING: Method definition f(Int64) in module Main at REPL[1]:1 overwritten at REPL[2]:1.
f (generic function with 1 method)

```

---

<div class="post-metadata">

**Author:** ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)\
**Post date:** [November 2, 2018, 1:29am UTC](https://discourse.julialang.org/t/overwriting-methods/17078/3 "2018-11-02T01:29:13Z")

</div>

Thanks! A warning is good enough. I was dealing with a bug where this would have helped weed out the error faster. I’ll keep it handy for next time.
