There is no need to do this in Julia; you can simply initialize in the 
default argument.

function f(x; y=[x, x, x])
    @show x y
end

then

julia> f(1)
x = 1
y = [1,1,1]

because in Julia, unlike Python, the initialization is done at calltime 
instead of function definition time.


On Friday, November 4, 2016 at 2:37:38 PM UTC-4, Alex wrote:
>
> Hi all, 
>
> I need to specify function parameter by default value None/Nothing like 
> in Python, so that if it is not initialized during the function call I 
> do it inside the function. 
>
> I read corresponding section in the FAQ: 
>
> http://docs.julialang.org/en/release-0.5/manual/faq/#nothingness-and-missing-values
>  
>
>
> And I still don't understand what is the proper way of doing this. 
>
> Should I do it like this? 
>
>
> ``` 
> function foo(x1,x2; z = Nullable{Int64}()) 
>     if isnull(z) 
>         ... 
>     else 
>         ... 
>     end 
> end 
> ``` 
>
> or in another way? 
>
>
> -- 
> BR, 
> Alex 
>

Reply via email to