Skip to content

Instantly share code, notes, and snippets.

@baransu
Last active July 28, 2016 22:40
Show Gist options
  • Save baransu/8162b5e205b0ec66e56a047ab88c7552 to your computer and use it in GitHub Desktop.
Save baransu/8162b5e205b0ec66e56a047ab88c7552 to your computer and use it in GitHub Desktop.
Syntactic sugar

###Switch


This is horrible (change required)

  • variant A
switch(type) {
   case value: 
   break;
   
   default:
   break;
}
  • variant B
switch(type) {
   case value: 
     return ...;
   
   default:
     return ...;
}
  • variant C (for scope based variables const, let)
switch(type) {
   case value: {
     return ...
   }
   
   default: {
     return ...
   }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment