<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 31, 2016, at 7:37 PM, Joe Groff &lt;<a href="mailto:jgroff@apple.com" class="">jgroff@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Sorry for piling onto the bikeshed. We do already have a notation for testing that an Optional isn't nil, `x != nil`. We could theoretically bless `&lt;decl ref&gt; != nil` as a statement condition to also unwrap the referenced declaration in the scope guarded by the condition. (`&lt;decl ref&gt; is T` could similarly rebind a declaration as the cast type.)<br class=""><br class="">-Joe<br class=""></div></div></blockquote><div><br class=""></div>Feels like too much magic. I'd like there to be a positive declaration of intent.</div><div><br class=""></div><div>The tl;dr of what I posted today is:</div><div><br class=""></div><div><div><font face="Menlo" class="">guard unwrap anOptional else { ... } // basic optional</font></div><div><span style="font-family: Menlo;" class="">if unwrap .string(myString) ~= jsonObject { ... } // Non-optional object</span></div></div><div><font face="Menlo" class="">if unwrap .contact(code, var message) ~= jsonObject { ... } // Multi-valued</font></div><div><font face="Menlo" class=""><br class=""></font></div><div><div><div><font face="Menlo" class="">if .some(let value) ~= anOptional { ... } // Pattern match operator instead of case</font></div></div><div><font face="Menlo" class="">if let value? ~= anOptional { ... } // ditto</font></div></div><div><br class=""></div><div>-- E</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class="">On Oct 28, 2016, at 3:34 PM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Oct 26, 2016, at 11:39 AM, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Oct 26, 2016, at 10:23 AM, Joshua Alvarado &lt;<a href="mailto:alvaradojoshua0@gmail.com" class="">alvaradojoshua0@gmail.com</a>&gt; wrote:<br class=""><br class="">In your example the keyword only makes sense if you are shadowing the optional variable. How would unwrap work with a different name?<br class=""></blockquote><br class="">It wouldn’t: “unwrap” would never include an equal sign. &nbsp;If you want to do that, use a standard "if let”.<br class=""><br class="">-Chris<br class=""></blockquote></blockquote></div></div></blockquote></div><br class=""></body></html>