<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br><div>Regards</div>(From<span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">&nbsp;mobile)</span></div><div><br>On Jun 23, 2016, at 8:51 PM, Charlie Monroe 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></span><br><blockquote type="cite"><span>On Jun 23, 2016, at 8:45 PM, Tim Vermeulen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>I would love to be able to do something like</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>doSomething(with: myOptional?)</span><br></blockquote><span></span><br><span>This actually looks good to me, though if I were a newcomer to the language, it would be really cryptic.</span><br><span></span><br><span>In case the function returned any value, it could become an optional, just like with try?...</span><br><span></span><br><span>I still, however, prefer the original proposal of if let myOptional! { doSomething(myOptional) }...</span><br><span></span><br></div></blockquote><div><br></div><div><div id="AppleMailSignature"><p style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; func doSomething&lt;T&gt; (with: t:T?, h:&nbsp;T&nbsp;-&gt; ()) {</span></p></div><div id="AppleMailSignature"><p style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;let&nbsp;t = self as?&nbsp;T&nbsp;{ h(t) }</span></p><p style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; }</span></p><p style="margin: 0px; line-height: normal;">extension Optional {</p></div></div><div><div id="AppleMailSignature"><p style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; func&nbsp;unwrap&lt;T&gt; (_&nbsp;h:&nbsp;T&nbsp;-&gt; ()) {</span></p></div><div id="AppleMailSignature"><p style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;let&nbsp;t = self as?&nbsp;T&nbsp;{ h(t) }</span></p><p style="margin: 0px; line-height: normal;"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; }</span></p></div></div>}<div><br></div><div>Var s2:Sting?&nbsp;</div><div><div id="AppleMailSignature"><p style="margin: 0px; line-height: normal;"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">s2.unwrap&nbsp;{ (str:String)&nbsp;in</span></font></p><p style="margin: 0px; line-height: normal;"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;print(":)")&nbsp;</span></font></p><p style="margin: 0px; line-height: normal;"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">}</span></font></p></div></div><div>doSomething(with:s2) { //same as above}</div><div><br></div><div>Nothing happens in both cases</div><div><br><blockquote type="cite"><div><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>which would be equivalent to</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>if let myValue = myOptional {</span><br></blockquote><blockquote type="cite"><span> &nbsp;&nbsp;doSomething(with: myValue)</span><br></blockquote><blockquote type="cite"><span>}</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>But it’s been discussed here before, and I don’t think people were very enthusiastic about it.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>I was wondering if people would be open to adding an unwrap method to the Optional type,I already have a method like this which shortens code for me.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>So this:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>let myReallyLongOptionalName: String? = "Hey"</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>if let string = myReallyLongOptionalName {</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>doSomethingWith(string)</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>}</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Could become"</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>let myReallyLongOptionalName: String? = "Hey"</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>myReallyLongOptionalName.unwrap {</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>doSomethingWith($0)</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>}</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>The block would only be fired if myReallyLongOptionalName has a value.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>___________________________________</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>James⎥Head of Trolls</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span><a href="mailto:james@supmenow.com">james@supmenow.com</a>(<a href="mailto:james@supmenow.com">mailto:james@supmenow.com</a>)⎥<a href="http://supmenow.com">supmenow.com</a>(<a href="http://supmenow.com">http://supmenow.com</a>)</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Sup</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Runway East</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>10 Finsbury Square</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>London</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>EC2A 1AF</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><span>_______________________________________________</span><br></blockquote><blockquote type="cite"><span>swift-evolution mailing list</span><br></blockquote><blockquote type="cite"><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br></blockquote><blockquote type="cite"><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></blockquote><span></span><br><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></div></body></html>