<div dir="ltr">Here's a few examples of what this change would allow. <div><br></div><div>I just plucked the first instances of other people's switch statements that I found on GitHub. </div><div><br></div><div>If there were an easy way to search GitHub for chained ternary expressions, I would have added some examples of those too, since they could all be improved with this where clause + ??. <div><br></div><div><p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(194,52,155)">mutating</span><span style=""> </span><span style="color:rgb(194,52,155)">func</span><span style=""> toggle() {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">                </span></span><span style="">switch</span><span style="color:rgb(255,255,255)"> </span><span style="">self</span><span style="color:rgb(255,255,255)">{</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                </span></span><span style="color:rgb(194,52,155)">case</span><span style=""> Off:</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                        </span></span><span style="color:rgb(194,52,155)">self</span><span style=""> = On</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                </span></span><span style="color:rgb(194,52,155)">case</span><span style=""> On:</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                        </span></span><span style="color:rgb(194,52,155)">self</span><span style=""> = Off<span class="" style="white-space:pre">        </span></span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                </span>}<span class="" style="white-space:pre">        </span></span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">        </span>}</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87)"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(194,52,155)">mutating</span><span style=""> </span><span style="color:rgb(194,52,155)">func</span><span style=""> toggle() {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87)"><span style=""><span class="" style="white-space:pre">                </span></span><span style="color:rgb(194,52,155)">self</span><span style=""> = .On </span><span style="color:rgb(194,52,155)">where</span><span style=""> (</span><span style="color:rgb(194,52,155)">self</span><span style=""> == .Off) ?? .Off</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87)"><span style=""><span class="" style="white-space:pre">        </span>}</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87);min-height:12px"><span style=""></span><br></p></div><div><br></div><div><p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">        </span></span><span style="color:rgb(194,52,155)">switch</span><span style=""> switchNumberThree {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                </span></span><span style="color:rgb(194,52,155)">case</span><span style=""> </span><span style="color:rgb(139,132,207)">10</span><span style="">, </span><span style="color:rgb(139,132,207)">11</span><span style="">, </span><span style="color:rgb(139,132,207)">12</span><span style="">:</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                        </span>println(</span><span style="color:rgb(228,68,72)">"It is </span><span style="">\</span><span style="color:rgb(228,68,72)">(</span><span style="">switchNumberThree</span><span style="color:rgb(228,68,72)">)"</span><span style="">)</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">                </span></span><span style="">default</span><span style="color:rgb(255,255,255)">:</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(228,68,72);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">                        </span>(</span><span style="">"It is none of them!"</span><span style="color:rgb(255,255,255)">)</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">        </span>}</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87)"><span style=""><span class="" style="white-space:pre">        </span>println(</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87)"><span style=""><span class="" style="white-space:pre">                </span></span><span style="color:rgb(228,68,72)">"It is </span><span style="">\</span><span style="color:rgb(228,68,72)">(</span><span style="">switchNumberThree</span><span style="color:rgb(228,68,72)">)"</span><span style=""> </span><span style="color:rgb(194,52,155)">where</span><span style=""> </span><span style="color:rgb(139,132,207)">10</span><span style="">...</span><span style="color:rgb(139,132,207)">12</span><span style=""> ~= switchNumberThree</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(228,68,72);background-color:rgb(0,30,87)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">                </span>?? </span><span style="">"It is none of them!"</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87)"><span style=""><span class="" style="white-space:pre">        </span>)</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87);min-height:12px"><span style=""></span><br></p></div><div><br></div><div><p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span></span><span style="">switch</span><span style="color:rgb(255,255,255)"> x {</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span></span><span style="">case</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(139,132,207)">1</span><span style="color:rgb(255,255,255)">:</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                </span>j++</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span></span><span style="">case</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(139,132,207)">2</span><span style="color:rgb(255,255,255)">:</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                </span>j++</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span></span><span style="">case</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(139,132,207)">3</span><span style="color:rgb(255,255,255)">:</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                </span>j++</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span></span><span style="">case</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(139,132,207)">4</span><span style="color:rgb(255,255,255)">:</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                </span>j++</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">                </span></span><span style="">fallthrough</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span></span><span style="">case</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(139,132,207)">5</span><span style="color:rgb(255,255,255)">:</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                </span>j++</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">                </span></span><span style="">fallthrough</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(194,52,155);background-color:rgb(92,7,0)"><span style="color:rgb(255,255,255)"><span class="" style="white-space:pre">        </span></span><span style="">default</span><span style="color:rgb(255,255,255)">:</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">                </span>j++</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0)"><span style=""><span class="" style="white-space:pre">        </span>}</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(92,7,0);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87);min-height:12px"><span style=""></span><br></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87)"><span style=""><span class="" style="white-space:pre">        </span>j = j+</span><span style="color:rgb(139,132,207)">1</span><span style=""> </span><span style="color:rgb(194,52,155)">where</span><span style=""> (</span><span style="color:rgb(139,132,207)">4</span><span style="">...</span><span style="color:rgb(139,132,207)">5</span><span style=""> ~= x) ?? j+</span><span style="color:rgb(139,132,207)">2</span></p>
<p style="margin:0px;font-size:10px;line-height:normal;font-family:'Fantasque Sans Mono';color:rgb(255,255,255);background-color:rgb(0,30,87);min-height:12px"><span style=""></span><br></p></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div>