Does the compiler continue evaluating an expression where all must be true if the first is false?

后端 未结 6 1935
误落风尘
误落风尘 2020-12-11 21:41

I\'m sure this question has probably been answered before, so I apologize, but I wasn\'t able to find the proper search terms to find the answer.

Given the following

6条回答
  •  不思量自难忘°
    2020-12-11 22:05

    No. The && operator short-circuits (which means it stops evaluating the expression after any part of the expression evaluates to false).

    The || operator also short-circuits but stops evaluating after any part of the expression evaluates to true.

提交回复
热议问题