It’s useful as a type stable default argument value. Assuming for a moment that Array{T, N}()
would create an empty array.
function f(x::Array{T, N}, weight = Array{T, N}()) where {T, N}
if isempty(weight)
# Compute unweighted special case.
else
# Compute the general case.
end
end
Yes, you could use nothing
to indicate no weight and being a small union it would probably be fast, but full type stability is still an attractive property.