Navigation Menu

Skip to content

Commit

Permalink
doc coding-style: add about boolean in condition
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Mar 15, 2012
1 parent 8b70463 commit 683f09f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions doc/source/developer/coding_style.rst
Expand Up @@ -431,3 +431,22 @@ bool型を用いる
悪い例( ``0`` 以外の値を真の値として用いている):

bool is_searching = 1;

条件式
------

真偽値は比較しない
^^^^^^^^^^^^^^^^^^

真偽値の値は ``boolean_value == true`` などとせず、 ``boolean_value`` として条件式に使用する。すでに真偽値の値を真偽値のリテラルと比較することは重複したコードだからである。

よい例:

boolean is_searching = true;
if (!is_searching) { ... }

悪い例(真偽値のリテラルと比較している):

boolean is_searching = true;
if (is_searching == false) { ... }

0 comments on commit 683f09f

Please sign in to comment.