Boolean operators && and ||

后端 未结 3 1866
醉酒成梦
醉酒成梦 2020-11-21 22:20

According to the R language definition, the difference between & and && (correspondingly | and ||) is that th

3条回答
  •  面向向阳花
    2020-11-21 23:02

    && and || are what is called "short circuiting". That means that they will not evaluate the second operand if the first operand is enough to determine the value of the expression.

    For example if the first operand to && is false then there is no point in evaluating the second operand, since it can't change the value of the expression (false && true and false && false are both false). The same goes for || when the first operand is true.

    You can read more about this here: http://en.wikipedia.org/wiki/Short-circuit_evaluation From the table on that page you can see that && is equivalent to AndAlso in VB.NET, which I assume you are referring to.

提交回复
热议问题