$ curl cheat.sh/
/*
 * I got around to installing it, but I have not found a way to specify
 * multiple, separate case labels for a single switch section with the
 * new syntax.
 * 
 * However, you can create a new variable that captures the value and
 * then use a condition to represent the cases that should have the same
 * result:
 */

 var resultText = switchValue switch
 {
     var x when
         x == 1 ||
         x == 2 ||
         x == 3 => "one to three",
     4 => "four",
     5 => "five",
     _ => "unknown",
 };

/*
 * This is actually more concise if you have many cases to test, because
 * you can test a range of values in one line:
 */

 var resultText = switchValue switch
 {
     var x when x > 0 && x < 4 => "one to three",
     4 => "four",
     5 => "five",
     _ => "unknown",
 };

// [Rufus L] [so/q/56676260] [cc by-sa 3.0]

$
Follow @igor_chubin cheat.sh