# Order of arguments in mutating functions

**URL:** <https://discourse.julialang.org/t/order-of-arguments-in-mutating-functions/45852>\
**Category:** New to Julia\
**Created:** [August 31, 2020, 5:54pm UTC](https://discourse.julialang.org/t/order-of-arguments-in-mutating-functions/45852 "2020-08-31T17:54:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ctkelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctkelley/32/10684_2.png) [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Post date:** [August 31, 2020, 5:54pm UTC](https://discourse.julialang.org/t/order-of-arguments-in-mutating-functions/45852/1 "2020-08-31T17:54:59Z")

</div>

I’m sure this has been asked before, but my searches came up empty. I have a function F that takes another function f and an array A as input. The function mutates A.

So is the order

F!(f,A) or F!(A,f)

The manual says

1. Function argument. Putting a function argument first permits the  
use of do blocks for passing multiline anonymous functions.

2. Input being mutated. For example, in fill!(x, v), x is the  
object being mutated and it appears before the value to be inserted into x.

So do I pick item 1 or item 3? I am leaning toward 1, but am not sure that is the correct thing.

---

<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:** [August 31, 2020, 5:59pm UTC](https://discourse.julialang.org/t/order-of-arguments-in-mutating-functions/45852/2 "2020-08-31T17:59:37Z")

</div>

I personally find `F!(f,A)` to be more clear.

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [August 31, 2020, 6:32pm UTC](https://discourse.julialang.org/t/order-of-arguments-in-mutating-functions/45852/3 "2020-08-31T18:32:13Z")

</div>

Putting the function first normally takes priority over mutating arguments to support `do` syntax.

---

<div class="post-metadata">

**Author:** ![lungben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lungben/32/12314_2.png) [@lungben](https://discourse.julialang.org/u/lungben)\
**Post date:** [August 31, 2020, 7:52pm UTC](https://discourse.julialang.org/t/order-of-arguments-in-mutating-functions/45852/4 "2020-08-31T19:52:24Z")

</div>

An example in the Base library is

```julia
filter!(f, A)

```
