Thursday, 8 March 2012

Condition Operator

I love this neat c trick: The condition operator. It makes my code so much tidier

e.g

return(x < 3)? YES : NO;

as opposed to:

if(x < 3){
         return YES;
}else{
         return NO;
}

1 comment:

  1. In this case would return (x < 3); not work more efficiently and be easier to read?

    ReplyDelete