Local scope is such a weird place to be ![]()
We can define named functions with type-specialized methods,
julia> f = let
function f(x::Int) x^2 end
function f(x::Float64) x/2 end
end
f (generic function with 2 methods)
julia> f(2)
4
julia> f(2.0)
1.0
and then throw them all away
julia> f = let
function f(x::Int) x^2 end
function f(x::Float64) x/2 end
f = 0
end
0
julia> f
0
It’s so bizarre
it feels like this ought to throw an error, the way it would at global scope.