Does inlining work when the function is passed as an argument?

Just wondering. For example

@inline function foo(x,y)
    @assert length(x) == length(y)
    x .+ y.*rand(length(y))

function apply_function(x,y,f)

julia> apply_function(rand(10), rand(10), foo)
1 Like

Yes, it can get inlined (but be aware of

As an aside, it’s a matter of convention to place function arguments first (even ahead of mutated arguments). This allows you to support do syntax.