I wish there was a DRY variant of the switch
construct that supported a concise syntax to filter a variable into several buckets for certain values, ranges, conditions or expressions without many case
statements and without any break
.
switch (foo) {
case 3, > 7: {do numeric stuff;}
case /^\d+/ || /\d+$/: {do stringy stuff;}
case undefined, NaN: {do exceptional stuff;}
}