Benefits of using short-circuit evaluation

后端 未结 15 1494
余生分开走
余生分开走 2020-12-05 16:23
boolean a = false, b = true;
if ( a && b ) { ... };

In most languages, b will not get evaluated because a is fals

15条回答
  •  -上瘾入骨i
    2020-12-05 16:54

    Depending upon the context, it can also be called "Guarding".

    And I've seen it in just about every language I've worked in - which pushes close to a dozen.

提交回复
热议问题