DEV Community

Discussion on: Language Proposal: The 'Any' Switch Case

Collapse
 
awwsmm profile image
Andrew (he/him) • Edited

What about a template case?

switch (number) {

  template:
      before: // do something before
       after: // do something after

  case 1: // ...

  template case 2: // ...

  template case 3: // ...

  case 4: // ...

  default: // ...

}

template could be applied to only a particular subset of cases, and the template definition could be extended to do exception handling, etc.