Are the default values then considered in a global scope? Not sure I fully
understand the doc:
http://docs.julialang.org/en/latest/manual/functions/#evaluation-scope-of-default-values
function foo(x,z=1)
... # z in global scope?
end
function foo2(x)
z=1 # Local scope
...
end
- Oliver
Den tirsdag den 1. april 2014 17.26.45 UTC+2 skrev Steven G. Johnson:
>
> Note that default arguments in Julia can simplify this further. Often you
> have Matlab code like
>
> function y = foo(x, z)
> if nargin < 2
> z = ...default value...
> end
> ....
> end
>
>
> Which in Julia can be simplified to
>
> function foo(x, z = ...default value...)
> ...
> end
>
>
> This is equivalent to declaring two functions, foo(x,z) and foo(x) =
> foo(x, ...default value...)
>