   A quick rant :)
  Why oh why do people write b = a > 0 ? 1 : 0 instead of...:?if ( a > 0 ) {b = 1; } else {b = 0; } The latter is so much more readable, especially if the condition test is complex.   
  The latter may be more readable if you''re more familiar with it. But I''d rather read (not to mention write) the former form. It has less code duplication and it''s shorter. When the ?:-operator, or several such, are embedded in a function call or some other longer expression, the savings will be even bigger. Now the duplicated part is just "b=", but it could be longer. Or alternatively, you''d need a temporary variable. ;  What I like about ?: is that it is a single expression. The ''if-else'' form is multiple statements.And wether it is readable depends on who is reading the code. ;Even worse:b = ( a > 0 ? 1 : ( a < 0 ? -1 : 0 ) )Its called code obfuscation. ;  It's only hard if you don't get it. I distinctly recall several occasions where I needed about 10 of those if's, and rather than writing 8 lines a peice, I wrote 1 per if. A savings of 70 lines.   [edited by - Puzzler183 on February 19, 2004 6:55:43 AM];quote:Original post by Puzzler183  It''s only hard if you don''t get it. I distinctly recall several occasions where I needed about 10 of those if''s, and rather than writing 8 lines a peice, I wrote 1 per if. A savings of 70 lines.   [edited by - Puzzler183 on February 19, 2004 6:55:43 AM]Oh, I can "read it" (just, but replace conditions with return results from functions etc.).  But unless you are running interpreted C/C++, it won''t make any difference to your running program, just quicker to type thats all!  Of course, if you are playing with your own code and nobody else needs to edit it, thats fine, otherwise, it isn''t! ;  "if/else" places too great an emphasis on the decision.  Oftentimes one is more interested in the value.For example, in something such as this: cout << "You have " << mailCount << " new mail" << (mailCount == 1 ? "" : "s") << "." << endl;one has little interest in the decision -- one is interested in the line of output.