[Groonga-mysql-commit] mroonga/mroonga [fix-for-visual-studio] doc coding-style: add about boolean in condition

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Oct 4 10:39:02 JST 2012


Kouhei Sutou	2012-03-15 18:04:54 +0900 (Thu, 15 Mar 2012)

  New Revision: 683f09f0ead69eb3edbdade8a17737bc41d40c64
  https://github.com/mroonga/mroonga/commit/683f09f0ead69eb3edbdade8a17737bc41d40c64

  Log:
    doc coding-style: add about boolean in condition

  Modified files:
    doc/source/developer/coding_style.rst

  Modified: doc/source/developer/coding_style.rst (+19 -0)
===================================================================
--- doc/source/developer/coding_style.rst    2012-03-15 18:01:19 +0900 (a0f2b9f)
+++ doc/source/developer/coding_style.rst    2012-03-15 18:04:54 +0900 (7d41507)
@@ -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) { ... }
+
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-mysql-commit mailing list
Back to archive index