Benefits of using short-circuit evaluation

后端 未结 15 1549
余生分开走
余生分开走 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条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 16:44

    i've only heard of it as short circuit. in a pipeline doesnt the next op that goes in depend on the outcome of the if statement? if that is the case this would more optimized so it wouldnt have to test two values every time.

提交回复
热议问题