Wolfbeast

Biased ternary comparison

Jan 5th, 2017 (edited)
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. Non-ternary:
  2.  
  3. type arg;
  4. if (something) {
  5. arg = a;
  6. } else {
  7. arg = b;
  8. }
  9. function(arg);
  10.  
  11. Ternary:
  12.  
  13. function(something ? a : b);
  14.  
  15. - Less complex to write
  16. - Less expensive for a compiler
  17. - No need for variable "arg" of the correct type
Add Comment
Please, Sign In to add comment