<div dir="ltr"><div>Sorry for the barrage here, Paul :)</div><div><br></div><div><span style="font-size:13px">> I’m not even convinced the new syntax is clearer so much as cleverer.</span><br></div><div><br></div>As I've followed the various threads for switch-like assignments, I've been thinking a lot about how valid it is to say that more explicit is all that helpful to beginners. I wish I had the resources to test these assumptions with actual people who had never written Swift.<br><div><br></div><div>As an example. </div><div><br></div><div>We assume that this:</div><div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(35,35,35)"> <span style="color:rgb(50,62,125)">let</span> phrase: <span style="color:rgb(88,126,168)">String</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(88,126,168)"><span style="color:rgb(35,35,35)"> </span><span style="color:rgb(50,62,125)">switch</span><span style="color:rgb(35,35,35)">( </span>temperature <span style="color:rgb(35,35,35)">) {</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(80,13,80)"> <span style="color:rgb(50,62,125)">case</span> .Cold: <span style="color:rgb(88,126,168)">str</span> = <span style="color:rgb(132,62,100)">"Too cold"</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(80,13,80)"> <span style="color:rgb(50,62,125)">case</span> .Hot: <span style="color:rgb(88,126,168)">str</span> = <span style="color:rgb(132,62,100)">"Too hot"</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(80,13,80)"> <span style="color:rgb(50,62,125)">default</span>: <span style="color:rgb(88,126,168)">str</span> = <span style="color:rgb(132,62,100)">"Just right"</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(80,13,80)"> }</p></div><div><br></div><div>is going to be easier for beginners than something like this:</div><div><br></div><div>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(35,35,35)"> <span style="color:rgb(50,62,125)">let</span> phrase = <span style="color:rgb(88,126,168)">temperature</span> ?</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(80,13,80)"> <span style="color:rgb(132,62,100)">"Too cold" </span><span style="color:rgb(35,35,35)">if </span>.Cold :</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(80,13,80)"> <span style="color:rgb(132,62,100)">"Too hot” </span><span style="color:rgb(35,35,35)">if</span><span style="color:rgb(132,62,100)"> </span>.Hot :</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(132,62,100)"><span style="color:rgb(80,13,80)"> </span>"Just right" <span style="color:rgb(35,35,35)">if _ </span><span style="color:rgb(80,13,80)"> </span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(80,13,80);min-height:13px"><br></p></div><div><div>I'm using a short version here that is not the actual proposal, and that we won't use (since we don't want to overload "if"). But I have a strong hunch that a beginner is not going to find the longer version any more clear. There's a lot of syntax for the programmer to parse in the "switch" statement, as it stands. I suspect the less redundancy we have, the easier it is to figure out what is going on.</div></div><div><br></div><div><br></div></div>