[H8-ML(4742)] Re: if文の書き方
From: hamayan <hamayan@xxxxxxxxxxxxxxxx>
Date: 2004年05月10日(月)15時38分39秒
hamayan です。

なんだか盛り上がっていますね!。
ところで、

Junsuke>   a = check_condition_a();
Junsuke>   b = check_condition_b();
Junsuke> 
Junsuke>   if (a && b) {
Junsuke>     正常処理;
Junsuke>   }

チェックする関数の戻り値が真か偽しか取らないなら、

   if(check_condition_a() && check_condition_b())
   {
     正常処理;
   }
とか、
   if
   ( <−また波紋を呼びそうだな!
      check_condition_a()
      && check_condition_b()
      && check_condition_c()
      && check_condition_d()
   )
   {
     正常処理;
   }

とした方が、aの条件で偽となった場合に、残りのチェックをせずに済むので、
処理が早くなるような・・・。
スレッド概略
[表示中](起点)


投稿順に移動
[←前の記事へ(P)]
[→次の記事へ(N)]


リスト表示へ
[このスレッド(T)]
[本記事の前後(L)]