<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 May 10, 2016, at 4:33 AM, Sam Dods via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I propose that <font face="Menlo" class=""><b class="">(case .Foo = bar)</b></font> should be treated as an expression with a Boolean value, so the result can be set to a variable or returned from a method.</div></div></div></blockquote><div><br class=""></div><div>I agree that this is an important use case that Swift doesn’t serve well right now, but I don’t think this is the right way to go. &nbsp;</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Considering the following enumeration:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class=""><b class="">enum Bar {</b></font></div><div class=""><font face="Menlo" class=""><b class="">&nbsp; case foo(name: String)</b></font></div><div class=""><font face="Menlo" class=""><b class="">&nbsp; case notFoo</b></font></div><div class=""><font face="Menlo" class=""><b class="">&nbsp; case unknownFoo</b></font></div><div class=""><font face="Menlo" class=""><b class="">}</b></font></div></div></div></blockquote><div><br class=""></div><div>One of the things we’ve discussed in the past is that we could have enums automatically “synthesize” instance members for projecting cases as optional values or bools. &nbsp;For example, the above enum could be compiled into the equivalent of:</div><div><br class=""></div><div>extension Bar {</div><div>&nbsp; &nbsp;func getAsFoo() -&gt; String? { … }</div><div>&nbsp; &nbsp;var isNotFoo : Bool { … }</div><div>&nbsp; &nbsp;var isUnknownFoo : Bool { … }</div><div>}</div><div><br class=""></div><div>Then you could just use:</div><div><br class=""></div><div>&nbsp; if someBar.isUnknownFoo { … }</div><div>&nbsp; if someBar.isFoo != nil { … }</div><div>&nbsp; if let name = someBar. getAsFoo() {... &nbsp;}</div><div>&nbsp; someBar.&nbsp;getAsFoo()?.doThing()&nbsp;</div><div><br class=""></div><div>etc. &nbsp;There is a question of naming, and getting the details right, of course.</div><div><br class=""></div><div>-Chris</div></div></body></html>