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))
end

function apply_function(x,y,f)
    f(x,y)
end

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

Yes, it can get inlined (but be aware of Performance Tips · The Julia Language).

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.