Skip to content

Instantly share code, notes, and snippets.

@md2perpe
Created March 24, 2017 08:38
Show Gist options
  • Save md2perpe/d3639194fdd8f5b774d8b9ddf17fb667 to your computer and use it in GitHub Desktop.
Save md2perpe/d3639194fdd8f5b774d8b9ddf17fb667 to your computer and use it in GitHub Desktop.
Switch instead of if
// Instead of
if (n == 42)
single_stmt;
// one can write
switch (n)
case 42:
single_stmt;
// Having no case makes the `single_stmt` not be run:
switch (n)
single_stmt; // Not run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment