<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><blockquote type="cite" class="clean_bq" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Correct, it is not ternary, just a slip of my mind :)</div></div></span></blockquote></div><p>I have a great amount of understanding for that, I find `nil coalescing operator` name simply impossible to remember :)</p><p><br></p><div><div><blockquote type="cite" class="clean_bq" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: 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><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><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>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. `try`, on the other hand, is an expression.</p><p>So you cannot simply `throw` the same way you cannot write:</p><p style="margin: 0px; font-size: 14px; line-height: normal; font-family: Monaco;"><span style="font-variant-ligatures: no-common-ligatures;">let</span><span style="font-variant-ligatures: no-common-ligatures;"> elem : </span><span style="font-variant-ligatures: no-common-ligatures;">AnyObject</span><span style="font-variant-ligatures: no-common-ligatures;"> = </span><span style="font-variant-ligatures: no-common-ligatures;">“42"</span></p><p style="margin: 0px; font-size: 14px; line-height: normal; font-family: Monaco;"><span style="font-variant-ligatures: no-common-ligatures;">let</span><span style="font-variant-ligatures: no-common-ligatures;"> int = elem </span><span style="font-variant-ligatures: no-common-ligatures;">as</span><span style="font-variant-ligatures: no-common-ligatures;">? Int ?? </span><span style="font-variant-ligatures: no-common-ligatures;">if</span><span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">true</span><span style="font-variant-ligatures: no-common-ligatures;"> { </span><span style="font-variant-ligatures: no-common-ligatures;">return</span><span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">42</span><span style="font-variant-ligatures: no-common-ligatures;"> }</span></p><p>but you can write:</p><p><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;"><span style="font-variant-ligatures: no-common-ligatures;">let</span><span style="font-variant-ligatures: no-common-ligatures;">&nbsp;elem :&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures;">AnyObject</span><span style="font-variant-ligatures: no-common-ligatures;">&nbsp;=&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures;">“42”</span></span></p><p><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">let</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">&nbsp;int =&nbsp;</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">elem</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">as</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">?&nbsp;</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">Int</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">&nbsp;?? {&nbsp;</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">if</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">true</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">&nbsp;{&nbsp;</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">return</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">42</span><span style="font-family: Monaco; font-size: 14px; font-variant-ligatures: no-common-ligatures;">&nbsp;} }()</span></p><p>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>Cheers!</p><p>Krzysztof</p><div></div></div></body></html>