<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="">so the rule would have to be that the “switch" or “if" must return a value of compatible type. Not sure I love all the braces in the “if" case but it does follow the existing language rules with the exception that it must be have an else.<div class=""><br class=""></div><div class="">let thisColor = if condition { .Red } // illegal for expressions but not statements</div><div class=""><br class=""></div><div class="">Can still do this for statements:</div><div class="">if condition {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>x = 40</div><div class="">}<br class=""><div class=""><br class=""></div><div class="">likewise:</div><div class="">let thisColor = if condition { .Red } else { 21 } // illegal unless thisColor is Any </div><div class=""><br class=""></div><div class="">unless: </div><div class=""><div class="">let thisColor : Any = if condition { .Red } else { 21 } // illegal unless thisColor is Any </div></div><div class=""><br class=""></div><div class="">It would be nice to omit braces in this expression case but not for statements: </div><div class="">let thisColor = if condition .Red else .Blue </div><div class=""><br class=""></div><div class="">in statements braces would be required: </div><div class=""><br class=""></div><div class="">if condition {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>x = 32</div><div class="">} else {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>y = 44</div><div class="">}</div><div class=""><br class=""><blockquote type="cite" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"></blockquote><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"></blockquote><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"></blockquote><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><span class="">> }</span></blockquote></div></div></blockquote><div><blockquote type="cite" class=""><div class="">On Dec 6, 2015, at 1:52 PM, Alex Lew via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I agree that it's simplest to just reuse switch keyword, and keep braces. +1. <div class=""><br class=""></div><div class="">Would you allow the same thing with if?<div class=""><br class=""></div><div class="">let thisColor = if condition { .Red } else { .Blue }</div></div></div><div class="gmail_extra" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""><div class="gmail_quote">On Sun, Dec 6, 2015 at 4:44 PM, Rudolf Adamkovic<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:salutis@me.com" target="_blank" class="">salutis@me.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><span class="">> On 06 Dec 2015, at 22:35, thorsten--- via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">><br class="">> I would prefer the expression to match the statement. The only difference would be that all parts that were statements now have to be expressions.<br class=""><br class=""></span>+1<br class=""><span class=""><br class="">><br class="">> Therefore the switch-expression should simply look like follows:<br class="">><br class="">> let thisColor = switch thatColor {<br class="">> case .Red: .Green // must be an expression<br class="">> default: .Yellow // must be an expression<br class="">> }<br class="">><br class="">> No returns needed in the case clauses.<br class=""><br class=""></span>This actually looks great. One simple rule and zero new keywords.<br class=""><br class="">Readable and simple to learn.<br class=""><br class="">Fantastic!<br class=""><span class="im HOEnZb"><br class="">> Formatting this as a one-liner would just require adding semicolons (though I wouldn't recommend this).<br class="">><br class="">> -Thorsten<br class=""></span><div class="HOEnZb"><div class="h5">> _______________________________________________<br class="">> swift-evolution mailing list<br class="">><span class="Apple-converted-space"> </span><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">><span class="Apple-converted-space"> </span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div></blockquote></div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=emrIhnP1hIf76Foxxv4NNJQX-2FWhcznESwKBSwD1MEwyP5CIr9PwUjY-2Ffl0vJP84s2E-2BPNmnmOU7FHbsypgjBVsA6XXVEIgefBIcq4-2BKrD6hXzZp9CEkFf-2FSAQvGZbuSiTLYT2uZ5LCc8U8KcITFXfDZ60W2ZWl5smFk598oozibBFsQxksuR4PHnB7FZ4Ohsb5TV78p5qHsJ7zZPfQPLXA-3D-3D" alt="" width="1" height="1" border="0" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span>_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></div></body></html>