Claim (false): Julia isn't multiple dispatch but overloading

Maybe this code will clarify a few things:

f(x::Int) = 3x
f(x::Real) = 4x

x = if ARGS[1] == "Int"
    3
else
    3.0
end

println("f(x) = ", f(x))

Running the code twice produces different results:

$ julia test.jl Int
f(x) = 9

$ julia test.jl Real
f(x) = 12.0

This is impossible using compiled languages like C++, because you would need to define the type of the variable at compilation time for overloading to work.

28 Likes