<div dir="ltr">Has there still not been a formal proposal for "Never as universal subtype/bottom"? Someone please propose it :)<div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Sat, Nov 12, 2016 at 12:20 AM, Adrian Zubarev via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@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 style="word-wrap:break-word"><div class="m_-8915201466734449250bloop_markdown"><p>I’ve build a custom operator for this: <a href="https://gist.github.com/DevAndArtist/dad641ee833e60b02fd1db2dbb488c6a" target="_blank">https://gist.github.com/<wbr>DevAndArtist/<wbr>dad641ee833e60b02fd1db2dbb488c<wbr>6a</a></p>
<pre><code class="m_-8915201466734449250swift">infix operator ?! : NilCoalescingPrecedence
func ?!<T>(optional: T?, noreturn: @autoclosure () -> Never) -> T {
switch optional {
case .some(let value):
return value
case .none:
noreturn()
}
}
// Usage
let test: Int? = nil
test ?! fatalError("Message")
</code></pre><span class="HOEnZb"><font color="#888888">
<p></p></font></span></div><div class="m_-8915201466734449250bloop_original_html"><span class="HOEnZb"><font color="#888888"><div id="m_-8915201466734449250bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div> <br> <div id="m_-8915201466734449250bloop_sign_1478938704115421184" class="m_-8915201466734449250bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div></font></span><div><div class="h5"> <br><p class="m_-8915201466734449250airmail_on">Am 6. Oktober 2016 um 05:35:53, Jonathan Hull via swift-users (<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>) schrieb:</p> <blockquote type="cite" class="m_-8915201466734449250clean_bq"><span><div><div></div><div>I used to be able to use ?? with fatalError(“Message”) to trap with a custom message in case of nil. This no longer works in Swift 3 (I think because of the update to never type)<br>______________________________<wbr>_________________<br>swift-users mailing list<br><a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br></div></div></span></blockquote></div></div></div><div class="m_-8915201466734449250bloop_markdown"><p></p></div></div><br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div></div>