Default value that doesn't correspond to an argument type

The default value is evaluated every time the function is called without an argument (and that’s a good thing, consider the common output=[] mistake in Python). It would be incorrect to output an error at function creation time:

julia> f(arg::String=nothing) = arg
f (generic function with 2 methods)

julia> nothing = "hello"
"hello"

julia> f()
"hello"
1 Like