<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Adding additional behavior to is/as that doesn't deal directly with types seems confusing to me. Those operators I feel would be best left for checking and casting types, despite how much nicer this reads.</div><div id="AppleMailSignature"><br>--<div>Kevin Lundberg</div></div><div><br>On Dec 8, 2015, at 5:31 AM, Andrew Bennett via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">I've wanted similar too. Although it may be better, instead of Bool, to have it as an optional tuple, the reason I suggest this is so that you can get the associated type. For example:<div><br></div><div>case let .Link(value,link) = self<br><div><div><br></div><div>So your example could be written:</div><div><br><div><div style="font-size:13px">func isEmpty() -> Bool {</div><div style="font-size:13px"> return (case .Empty = self) != nil</div><div style="font-size:13px">}</div></div><div style="font-size:13px"><br></div><div style="font-size:13px">However I'm not sure about this syntax, perhaps something like this:</div></div></div></div><div style="font-size:13px"><br></div><div style="font-size:13px"><div><div>func isEmpty() -> Bool {</div><div> return self is case .Empty</div><div>}</div></div><div><br></div></div><div style="font-size:13px">Alternatively if you want the value you could do:</div><div style="font-size:13px"><br></div><div style="font-size:13px">let (value, link) = self as? case .Link</div><div style="font-size:13px"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 8, 2015 at 3:05 PM, Alex Lew via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>Curious to hear thoughts on allowing non-binding pattern matches to be used as boolean values outside of an if, guard, for...in, while, switch, etc. Something like:</div><div><br></div><div>enum List<T> {</div><div> case Empty</div><div> indirect case Link(T, List<T>)</div><div> </div><div> func isEmpty() -> Bool {</div><div> return case .Empty = self</div><div> }</div><div>}</div><div><br></div><div>It gets rid of some boilerplate (explicit return true and return false), and seems intuitive that it would work given that you can already do </div><div><br></div><div>if case .Empty = self {</div><div> return true</div><div>} else {</div><div> return false</div><div>}</div><div><br></div><div>I haven't really thought through all the implications here, so there's probably something I'm missing. It also may be useful only in such limited situations that it's not worth the trouble to add.</div><div><br></div><div>-Alex</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=pQw7h83fWt3LLbgkfL4TSUL0weaZnVFZxDe5GShw4uQKig8LXmLi-2FUsCzoi5yRXiPxzHDvc4wSqEwQaEi7TJV4y5h2e3qczvNTeVB9QPt4seuH2cHkii9-2BunUbImKtSt5gP9CaQyn-2BVofjJ8S5Y1CTjT7zhQcJrruz5l-2FPWli-2FR-2BtMAUvVQ7NUy2fIsoAWPO-2BTNuUEBi56gBSBbPRiNyGIHXsLDmNE9hkpo0loQIJBk-3D" alt="" width="1" height="1" border="0" style="min-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">
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=AxVqvhl7qaAz-2FE20TrrgNT-2F44XdgxmRgRA416dJII-2BQZ55PWY-2F9KMaL88meYmMzNqW38ceptP19UZ-2BWa1aZCAzgyZ4hhojl5wJaiHQX9xLOu0Fi7KCIlTKS65vD-2FbSDJ7ySWEBjWwc3ujSubbdMS34BMs-2FqQYUCNRlsRAW-2FF1BOlca-2BQmlGokAV0VVsjxoMC2YUPNJgP-2BoEeAJJgBF1QUixDHjssnJ75PGRulJx-2B-2FYk-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>