Skip to main content
3 of 3
Improve code formatting
Maya
  • 5.8k
  • 1
  • 27
  • 40

Use ternary operators

if(a==2){some code;}else{some other code;} 

can be abbreviated to this:

(a==2?some code:some other code); 

Shorter, huh?