julia> function foo(a,b) a *= "+1"; b *= "+2"; return a,b end
julia> function baz() a="";b=""; (true) ? a,b = foo("","") : nothing; println(a,b) end
ERROR: syntax: colon expected in "?" expression
Stacktrace:
[1] top-level scope
@ none:1
So it doesn’t like something in the first branch (that with the a,b = foo("","")
so lets wrap it in parenthesis.
julia> function baz() a="";b=""; (true) ? (a,b) = foo("","") : nothing; println(a,b) end
julia> baz()
+1+2
Fine, now it works. But why doesn’t it work if we instead do (a,b = foo("",""))
?
Note that this was the real case that broke my code and made spend quite some time debugging it.
julia> function baz() a="";b=""; (true) ? (a,b = foo("","")) : nothing; println(a,b) end
julia> baz()