Friday, November 12, 2010

Conditional Operator

The following code:

   return a1<a2?true:
             b1<b2?true:
                c1<c2?true:
                   false;

is functionally equivalent to:

   if (a1 < a2) {
      return true;
   } else if (b1 < b2) {
      return true;
   } else if (c1 < c2) {
      return true;
   } else {
      return false;
   }

No comments:

Post a Comment