Hard to say without the context, but since in this case the only purpose
of a `nothing` seems to be to initialize with a default value, I would
go with y=Dict(), which does it directly.

(Note that unless you are dispatching on them, your type declarations
are probably unnecessary, they won't make your code faster.)

On Thu, May 05 2016, FANG Colin wrote:

> For example,
>
> function f(x::Int; y::Union{Void, Dict})
>     z = y == nothing ? Dict() : y
>     ...
> end
>
>
> Or
>
> function f(x::Int; y::Dict=Dict())
>     ...
> end
>
> Which one should I use?

Reply via email to