0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

orやandの処理順番

Posted at

一つのif文に何個も条件を付けたときに、

if (isHoge || ok || flg && hasFuga && (enabled || allowed)) {...

などと||&&を使うと思いますが

こいつらの処理順番がどうなっているか知っていますでしょうか?

カッコ内が最速なのはご存じだと思いますが、
&&のほうが||より計算されるのが早いのです。

簡単な話、結局
||は足し算、
&&は掛け算なのです。

この話を先輩に聞いたときに なるほど!となったのでここに書き記してみました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?