<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 2, 2016, at 6:41 AM, Krzysztof Siejkowski 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 style="font-family: Helvetica, Arial; font-size: 13px; 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=""><blockquote type="cite" class="clean_bq" style="font-family: Helvetica, Arial; font-size: 13px; font-style: 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;"><span class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">Correct, it is not ternary, just a slip of my mind :)</div></div></span></blockquote></div><p style="font-family: Helvetica, Arial; font-size: 13px; 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 have a great amount of understanding for that, I find `nil coalescing operator` name simply impossible to remember :)</p><p style="font-family: Helvetica, Arial; font-size: 13px; 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=""><br class=""></p><div style="font-family: Helvetica, Arial; font-size: 13px; 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=""><div class=""><blockquote type="cite" class="clean_bq" style="font-family: Helvetica, Arial; font-size: 13px; font-style: 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;"><span class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="">I didn’t know this workaround worked. Cool! Can somebody from the core team tell us if it not supporting throw directly is a bug or an intended feature?</div></div></div></span></blockquote></div><p class="">Just to elaborate a little after I thought about it for a minute: intended feature. The core reason is that `throw` is a statement (the same way as `if` or `guard` are), and in Swift statements are not expressions. </p></div></div></blockquote><div>Yep, Krzysztof is exactly right here. It would be possible to turn “throw” into an expression - this is precedented in other languages (like C++ iirc).</div><div><br class=""></div><div>-Chris</div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica, Arial; font-size: 13px; 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=""><p class="">`try`, on the other hand, is an expression.</p><p class="">So you cannot simply `throw` the same way you cannot write:</p><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Monaco;" class=""><span class="">let</span><span class=""><span class="Apple-converted-space"> </span>elem :<span class="Apple-converted-space"> </span></span><span class="">AnyObject</span><span class=""><span class="Apple-converted-space"> </span>=<span class="Apple-converted-space"> </span></span><span class="">“42"</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Monaco;" class=""><span class="">let</span><span class=""><span class="Apple-converted-space"> </span>int = elem<span class="Apple-converted-space"> </span></span><span class="">as</span><span class="">? Int ??<span class="Apple-converted-space"> </span></span><span class="">if</span><span class=""><span class="Apple-converted-space"> </span></span><span class="">true</span><span class=""><span class="Apple-converted-space"> </span>{<span class="Apple-converted-space"> </span></span><span class="">return</span><span class=""><span class="Apple-converted-space"> </span></span><span class="">42</span><span class=""><span class="Apple-converted-space"> </span>}</span></div><p class="">but you can write:</p><p class=""><span style="font-family: Monaco; font-size: 14px;" class=""><span class="">let</span><span class=""> elem : </span><span class="">AnyObject</span><span class=""> = </span><span class="">“42”</span></span></p><p class=""><span style="font-family: Monaco; font-size: 14px;" class="">let</span><span style="font-family: Monaco; font-size: 14px;" class=""> int = </span><span style="font-family: Monaco; font-size: 14px;" class="">elem</span><span style="font-family: Monaco; font-size: 14px;" class=""> </span><span style="font-family: Monaco; font-size: 14px;" class="">as</span><span style="font-family: Monaco; font-size: 14px;" class="">? </span><span style="font-family: Monaco; font-size: 14px;" class="">Int</span><span style="font-family: Monaco; font-size: 14px;" class=""> ?? { </span><span style="font-family: Monaco; font-size: 14px;" class="">if</span><span style="font-family: Monaco; font-size: 14px;" class=""> </span><span style="font-family: Monaco; font-size: 14px;" class="">true</span><span style="font-family: Monaco; font-size: 14px;" class=""> { </span><span style="font-family: Monaco; font-size: 14px;" class="">return</span><span style="font-family: Monaco; font-size: 14px;" class=""> </span><span style="font-family: Monaco; font-size: 14px;" class="">42</span><span style="font-family: Monaco; font-size: 14px;" class=""> } }()</span></p><p class="">There has been already a few discussions whether statements should be expressions in swift or not on the list, which I’ve been only partially following, so I’m not sure if there’re any plans for changing the current statement/expression tradeoff is Swift :)</p><p class="">Cheers!</p><p class="">Krzysztof</p><div class=""></div></div><span style="font-family: Helvetica, Arial; font-size: 13px; 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><br style="font-family: Helvetica, Arial; font-size: 13px; 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, Arial; font-size: 13px; 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, Arial; font-size: 13px; 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, Arial; font-size: 13px; 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, Arial; font-size: 13px; 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, Arial; font-size: 13px; 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=""></body></html>