Suppose I have a function that returns two values, but I am usually only interested in the first one.
nit = 0
res = 1.
while res > 0.1 && nit < 500
nit += 1
res /= 1 + res
return res, nit
The typical way to signal to someone reading my code that I am not going to use the
nit value would be to write
R, _ = foo()
However, I figured out that in Julia I can simply write
R = foo()
to the same effect.
Is this poor style?
julia> function foo()
foo (generic function with 1 method)
julia> R = foo();
not the same?
Indeed it is not. Turns out I had renamed my function along the way and
R = foo() worked by referencing the old name.
A similar issue is whether this is bad style:
julia> x, = 1,2
For me the answer is yes, but really it’s bad that Julia allows that at all.