<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">we sorta have this with switch guards<div><br></div><div><div style="background-color:rgb(28,31,34);padding:0px 0px 0px 2px"><div style="color:rgb(199,205,209);font-family:Consolas;white-space:pre"><p style="margin:0px"><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(255,0,127)">switch</span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(249,250,244)">(</span><span style="color:rgb(207,191,173)">intyMcIntFace</span><span style="color:rgb(249,250,244)">)</span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(249,250,244)">{</span></p><p style="margin:0px"><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(255,0,127)">case</span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(82,227,246)">Integer</span><span style="color:rgb(207,191,173)"> i </span><span style="color:rgb(197,104,28)">when</span><span style="color:rgb(207,191,173)"> i </span><span style="color:rgb(255,0,127)">></span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(196,140,255)">1</span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(255,0,127)">&&</span><span style="color:rgb(207,191,173)"> i </span><span style="color:rgb(255,0,127)"><</span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(196,140,255)">10</span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(255,0,127)">-></span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(249,250,244)">{}</span></p><p style="margin:0px"><span style="color:rgb(207,191,173)"> </span></p><p style="margin:0px"><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(255,0,127)">case</span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(196,140,255)">42</span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(255,0,127)">-></span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(249,250,244)">{}</span></p><p style="margin:0px"><br></p><p style="margin:0px"><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(255,0,127)">default</span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(255,0,127)">-></span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(255,0,127)">throw</span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(255,0,127)">new</span><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(167,236,33)">IllegalArgumentException</span><span style="color:rgb(249,250,244)">(</span><span style="color:rgb(236,228,126)">"Unexpected value: "</span><span style="color:rgb(249,250,244)">)</span><span style="color:rgb(255,0,127)">;</span></p><p style="margin:0px"><span style="color:rgb(207,191,173)"> </span><span style="color:rgb(249,250,244)">}</span></p></div></div></div></div></div><input name="virtru-metadata" type="hidden" value="{"email-policy":{"disableCopyPaste":false,"disablePrint":false,"disableForwarding":false,"enableNoauth":false,"expandedWatermarking":false,"expires":false,"sms":false,"expirationNum":1,"expirationUnit":"days","isManaged":false,"persistentProtection":false},"attachments":{},"compose-id":"3","compose-window":{"secure":false}}"></div></div><br><div class="gmail_quote" style=""><div dir="ltr" class="gmail_attr">On Wed, Mar 13, 2024 at 8:16 AM Red IO <<a href="mailto:redio.development@gmail.com">redio.development@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">The switch statement saw a huge transformation over the past few releases. So I was quite surprised to realize that the current switch construct can't check the range of an value.<div dir="auto">Example case x is between y and z.</div><div dir="auto">I'm most likely not the first one to notice that. Is there any discussion about adding some sort of range pattern? Would fit in the notion of the switch checking patterns quite well. </div><div dir="auto"><br></div><div dir="auto">Great regards </div><div dir="auto">RedIODev </div></div>
</blockquote></div></div>