<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>What if you could wrap the existing switch statement in a closure and return a value from that closure like so</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Let value = { switch (other) {</div><div id="AppleMailSignature">Case .Some(let value):</div><div id="AppleMailSignature">Return value // because this is in a closure the closure will return the value not the function this is in</div><div id="AppleMailSignature">Case .None:</div><div id="AppleMailSignature">Return "hello"&nbsp;</div><div id="AppleMailSignature">}}</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature"><br>Sent from my iPhone</div><div><br>On 29 Dec 2015, at 07:53, Howard Lovatt via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><div class="" style="margin: 0px; line-height: normal;"><font class="" style="background-color: rgba(255, 255, 255, 0);">You can replace the proposed statement `which` (another thread), the existing statement `?:` (this thread), and the global function `??` (which is an odd ball) with matching library methods.</font></div><div class="" style="margin: 0px; line-height: normal;"><font class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font class="" style="background-color: rgba(255, 255, 255, 0);">A library method is likely slower than a built in at this stage until the optimiser improves, but a library function:</font></div><div class="" style="margin: 0px; line-height: normal;"><font class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><ol class="MailOutline"><li class=""><font class="" style="background-color: rgba(255, 255, 255, 0);">Is documented right in the IDE including code completion, statements aren’t (you don’t see quick help for `for`!)</font></li><li class=""><font class="" style="background-color: rgba(255, 255, 255, 0);">Having a library function allows the use case to be throughly investigated. Is worth while as a language statement? What exact features are useful? EG should `which` support pattern matching, general boolean expressions, or simply be `Equatable` as shown below?</font></li><li class=""><font class="" style="background-color: rgba(255, 255, 255, 0);">It is simpler to implement, maintain, and change a library function that a built-in.</font></li><li class=""><font class="" style="background-color: rgba(255, 255, 255, 0);">There is no need for a keyword.</font></li></ol></div><div class="" style="margin: 0px; line-height: normal;"><font class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font class="" style="background-color: rgba(255, 255, 255, 0);">First `which`:</font></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">// Alternative to introducing `which` statement</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">final</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">class</span>&nbsp;Which&lt;I: Equatable, R&gt; {</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">&nbsp; &nbsp;&nbsp;</span>private</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;<span class="">var</span>&nbsp;result:&nbsp;<span class="">R</span>?</span></div><p class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp;&nbsp; &nbsp;</span></p><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">&nbsp; &nbsp;&nbsp;</span>private</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;<span class="">let</span>&nbsp;which:&nbsp;<span class="">I</span></span></div><p class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp;&nbsp; &nbsp;</span></p><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;<span class="">init</span>(<span class="">_</span>&nbsp;which:&nbsp;<span class="">I</span>) {</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">self</span>.<span class="">which</span>&nbsp;= which</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; }</span></div><p class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp;&nbsp; &nbsp;</span></p><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;<span class="">func</span>&nbsp;match(value: I,&nbsp;<span class="">@noescape</span>&nbsp;matchResult: ()&nbsp;<span class="">throws</span>&nbsp;-&gt; R)&nbsp;<span class="">rethrows</span>&nbsp;-&gt;&nbsp;<span class="">Self</span>&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">if</span>&nbsp;<span class="">self</span>.<span class="">result</span>&nbsp;==&nbsp;<span class="">nil</span>&nbsp;&amp;&amp;&nbsp;<span class="">self</span>.<span class="">which</span>&nbsp;<span class="">==</span>&nbsp;value {</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">self</span>.<span class="">result</span>&nbsp;=&nbsp;<span class="">try</span>&nbsp;matchResult()</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span>return<span class="">&nbsp;</span>self</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; }</span></div><p class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp;&nbsp; &nbsp;</span></p><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;<span class="">func</span>&nbsp;matchDefault(<span class="">@noescape</span>&nbsp;defaultResult: ()&nbsp;<span class="">throws</span>&nbsp;-&gt; R)&nbsp;<span class="">rethrows</span>&nbsp;-&gt;&nbsp;<span class="">R</span>&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">switch</span>&nbsp;<span class="">self</span>.<span class="">result</span>&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">case</span>&nbsp;.None:</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">return</span>&nbsp;<span class="">try</span>&nbsp;defaultResult()</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">case</span>&nbsp;.Some(<span class="">let</span>&nbsp;value):</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">return</span>&nbsp;value</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; }</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">}</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">// Demo</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">enum</span>&nbsp;Color {</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;<span class="">case</span>&nbsp;Red, Blue, Green</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">}</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">// Which with a default value</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">let</span><span class="">&nbsp;i1 =&nbsp;</span><span class="">Which</span><span class="">(</span><span class="">Color</span><span class="">.</span><span class="">Red</span><span class="">)&nbsp;</span>// i =&nbsp;<a dir="ltr" href="tel:16711680" x-apple-data-detectors="true" x-apple-data-detectors-type="telephone" x-apple-data-detectors-result="0">16711680</a></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; .<span class="">match</span>(.<span class="">Red</span>) &nbsp; {&nbsp;<span class="">0xFF0000</span>&nbsp;}</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; .<span class="">match</span>(.<span class="">Green</span>) {&nbsp;<span class="">0x00FF00</span>&nbsp;}</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; .<span class="">match</span>(.<span class="">Blue</span>)&nbsp; {&nbsp;<span class="">0x00000FF</span>&nbsp;}</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">&nbsp; &nbsp; .</span>matchDefault<span class="">&nbsp; {&nbsp;</span><span class="">0</span><span class="">&nbsp;}</span></span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">// Which that throws an error if it defaults</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">let</span><span class="">&nbsp;i2:&nbsp;</span><span class="">Int</span><span class="">! =&nbsp;</span><span class="">Which</span><span class="">(</span><span class="">Color</span><span class="">.</span><span class="">Green</span><span class="">)&nbsp;</span>// i =&nbsp;<a dir="ltr" href="tel:16711680" x-apple-data-detectors="true" x-apple-data-detectors-type="telephone" x-apple-data-detectors-result="1">16711680</a></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; .<span class="">match</span>(.<span class="">Red</span>) &nbsp; {&nbsp;<span class="">0xFF0000</span>&nbsp;}</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; .<span class="">match</span>(.<span class="">Green</span>) {&nbsp;<span class="">0x00FF00</span>&nbsp;}</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; .<span class="">match</span>(.<span class="">Blue</span>)&nbsp; {&nbsp;<span class="">0x00000FF</span>&nbsp;}</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">&nbsp; &nbsp; .</span><span class="">matchDefault</span><span class="">&nbsp; {&nbsp;</span><span class="">nil</span><span class="">&nbsp;}&nbsp;&nbsp;</span>// Cant type call to fatalError as no return, hence nil and type Int! (note !)</span></div></blockquote><font class="" style="background-color: rgba(255, 255, 255, 0);"><div id="AppleMailSignature"><font class="" style="background-color: rgba(255, 255, 255, 0);"><br></font></div>Note runtime check for default rather than static check via compiler, not as good but not a big deal most of the time. The vast majority of languages don't do a compiler check on `switch`.</font></div><div id="AppleMailSignature"><font class="" style="background-color: rgba(255, 255, 255, 0);"><br class="">Similarly the `?:` statement can be replaced:<br class=""><br class=""></font><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">// Replacement for `?:` operator</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">struct</span>&nbsp;IfFalse&lt;R&gt; {</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">&nbsp; &nbsp;&nbsp;</span>private</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;<span class="">let</span>&nbsp;result:&nbsp;<span class="">R</span>?</span></div><p class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp;&nbsp; &nbsp;</span></p><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;<span class="">func</span>&nbsp;ifFalse(<span class="">@noescape</span>&nbsp;falseResult: ()&nbsp;<span class="">throws</span>&nbsp;-&gt; R)&nbsp;<span class="">rethrows</span>&nbsp;-&gt;&nbsp;<span class="">R</span>&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">switch</span>&nbsp;<span class="">self</span>.<span class="">result</span>&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">case</span>&nbsp;.None:</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">return</span>&nbsp;<span class="">try</span>&nbsp;falseResult()</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">case</span>&nbsp;.Some(<span class="">let</span>&nbsp;value):</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">return</span>&nbsp;value</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; }</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">}</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">extension<span class="">&nbsp;</span><span class="">Bool</span><span class="">&nbsp;{</span></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;<span class="">func</span>&nbsp;ifTrue&lt;R&gt;(<span class="">@noescape</span>&nbsp;trueResult: ()&nbsp;<span class="">throws</span>&nbsp;-&gt; R)&nbsp;<span class="">rethrows</span>&nbsp;-&gt;&nbsp;<span class="">IfFalse</span>&lt;<span class="">R</span>&gt; {</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">switch</span>&nbsp;<span class="">self</span>&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">case</span>&nbsp;<span class="">true</span>:</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">return</span>&nbsp;<span class="">IfFalse</span>(result:&nbsp;<span class="">try</span>&nbsp;trueResult())</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">case</span>&nbsp;<span class="">false</span>:</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">return</span>&nbsp;<span class="">IfFalse</span>(result:&nbsp;<span class="">nil</span>)</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; }</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">}</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">// Demo</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">let</span><span class="">&nbsp;sB =&nbsp;</span><span class="">true</span><span class="">.</span><span class="">ifTrue</span><span class="">{</span><span class="">"True"</span><span class="">}.</span><span class="">ifFalse</span><span class="">{</span><span class="">"False"</span><span class="">}&nbsp;</span>// "True" - for some reason needs {} and not () thinks () form throws</span></div></blockquote><font class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></font><div class="" style="margin: 0px; line-height: normal;"><font class="" style="background-color: rgba(255, 255, 255, 0);">Whilst the `??` operator is already a library function it is difficult to see in an expression, it gets&nbsp;buried, and is inconsistent in style because it is a non-mathematical operator and a symbol rather than a keyword or keyword followed by a symbol. The space either side of the `??` operator also makes it look like both arguments are of equal importance, whereas it is the left hand side that is important and the right hand side is just a catch.</font></div><font class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></font><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">// Replacement for `??` operator</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">extension<span class="">&nbsp;</span><span class="">Optional</span><span class="">&nbsp;{</span></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;<span class="">func</span>&nbsp;ifNil(<span class="">@noescape</span>&nbsp;nilResult: ()&nbsp;<span class="">throws</span>&nbsp;-&gt; Wrapped)&nbsp;<span class="">rethrows</span>&nbsp;-&gt;&nbsp;<span class="">Wrapped</span>&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">switch</span>&nbsp;<span class="">self</span>&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">case</span>&nbsp;.None:</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">return</span>&nbsp;<span class="">try</span>&nbsp;nilResult()</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">case</span>&nbsp;.Some(<span class="">let</span>&nbsp;value):</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="">return</span>&nbsp;value</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; }</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">}</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">// Demo</span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">let</span>&nbsp;o:&nbsp;<span class="">String</span>? =&nbsp;<span class="">nil</span></span></div><div class="" style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);"><span class="">let</span><span class="">&nbsp;sO =&nbsp;</span><span class="">o</span><span class="">.</span><span class="">ifNil</span><span class="">{</span><span class="">"Nil"</span><span class="">}&nbsp;</span>// "Nil" - for some reason needs {} and not () thinks () form throws</span></div></blockquote><font class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></font><span style="-webkit-text-size-adjust: auto;"></span><br>Sent from my iPad</div><div><br>On 29 Dec 2015, at 4:00 AM, Thorsten Seitz via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><span>No exhaustiveness checking is a serious deficiency :-(</span><br><span></span><br><span>-Thorsten</span><br><span></span><br><blockquote type="cite"><span>Am 17.12.2015 um 08:09 schrieb Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Actually, this *almost* does what you want. No @autoclosure for the values and no exhaustiveness checking, but otherwise...</span><br></blockquote><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=xV0JY-2FdZMnUMvSFtZnLiBPRTDDOSQf3-2FpH33HYOlBxGuyq5t-2F3EGwb-2Fp-2FEknhUTetpoZ0Wf7T5ZvniexKcrPvo8tEDpvK-2BQtk9RzQpHso5fez-2BSQ2LDBkL9Ks5k8VGQKnbFrslKf-2FARG4G9z4e4A96v5QWrKAdGbpnbuQ8sMN5cXOOeeXx4a29EVMBG63w4wkj1yJ6CgFuVL-2FoAP9XmmlelXHKqzZkOxZtQ9xv5uowE-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">

</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>