chrisvoncsefalvay / learn-julia-the-hard-way

Learn Julia the hard way!
https://app.gitbook.com/@chrisvoncsefalvay/s/learn-julia-the-hard-way/
Other
772 stars 153 forks source link

Short-Circuit Evaluation != Bitwise Operators #43

Open erwingelissen opened 7 years ago

erwingelissen commented 7 years ago

In chapter 6 section combining-comparisons: "Comparisons can be combined using the boolean operators && (and) and || (or)."

I think it would be better not to blend the Bitwise Operators (& and |) with the operators for Short-Circuit Evaluation (&& and ||). The Bitwise Operators require both operands to be Boolean values. When using the Short-Circuit operators then the last operand can be any random expression.

    julia> (π > 2) & (π < 3)
    false

    julia> (π > 2) | (π < 3)
    true

    julia> (π > 2) && println("Short-Circuit Evaluation")
    Short-Circuit Evaluation