Julia 1.4.2
The behaviour that stumps me occurs in the first and fourth cases:
julia> if (val = (1 == 2))
println(val)
end
julia> if (val = (1 == 1))
println(val)
end
true
julia> if (val = (1 == 1))
println(val + 5)
end
6
julia> if (val = (1 == 2))
println(val + 5)
end
julia> 1 == 2
false
julia> 1 == 1
true
julia> println(1==2)
false
julia> println(1==1)
true
I observe this in the REPL and in Jupyter.
My questions are:
- Why does this happen?
- How can I retrieve the value of
val, preferably the "truthy" value, in both cases?