Benefits of using short-circuit evaluation

后端 未结 15 1548
余生分开走
余生分开走 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:50

    Languages supporting short-circuiting:

    Ada, Eiffel, ALGOL 68, C1, C++, C#, Java, R, Erlang, Standard ML, Javascript, MATLAB, Lisp, Lua, Scheme, OCaml, Haskell, Pascal,Perl, Ruby, PHP, Python, Smalltalk, Visual Basic .NET

    Taken from Short-circuit evaluation

提交回复
热议问题