Advertisement
uniblab

3 stupid and wrong ways of formatting conditionals (and One Right Way)

Mar 30th, 2021
1,298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. // WRONG!
  2. if ( foo == bar || bar == baz || baz == quux ) {
  3.     // code here
  4. }
  5.  
  6. // WRONG!
  7. if ( foo == bar
  8.     || bar == baz
  9.     || baz == quux ) {
  10.     // code here
  11. }
  12.  
  13. // WRONG!
  14. if ( foo == bar
  15.     || bar == baz
  16.     || baz == quux )
  17. {
  18.     // code here
  19. }
  20.  
  21.  
  22. // CORRECT
  23. if (
  24.     ( foo == bar )
  25.     || ( bar == baz )
  26.     || ( baz == quux )
  27. ) {
  28.     // code here
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement