StaticLint.jl icon indicating copy to clipboard operation
StaticLint.jl copied to clipboard

Warn for conditional function definition in local scopes

Open pfitzseb opened this issue 5 years ago • 0 comments

function f()
    if rand() < 0.5
        g(x) = x
    else
        g(x) = 2x
    end
    g
end

should be written as

function f()
    if rand() < 0.5
        g = x -> x
    else
        g = x -> 2x
    end
    g
end

instead.

pfitzseb avatar Nov 19 '20 17:11 pfitzseb