Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Order of arguments in mutating functions

$
0
0

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.

4 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images