<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Yeah, sorry did that kind of quick. Just trying to express the idea, maybe my implementation left something to be desired. I wanted the result not the optional. </div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 15, 2016, at 10:35 PM, Thorsten Seitz <<a href="mailto:tseitz42@icloud.com" class="">tseitz42@icloud.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""></div><div class=""><br class=""></div><div class="">Am 16.02.2016 um 05:52 schrieb Paul Ossenbruggen via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>:<br class=""><br class=""></div><blockquote type="cite" class=""><div class="">I guess if auto closure could take a parameter you could do something like this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">@warn_unused_result</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">public</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> ??<T>(optional: T?, <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">@autoclosure</span> defaultValue: (result : T) <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">throws</span> -> T) <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">rethrows</span> -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span> {</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> optional != <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nil</span> ? optional! : <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">try</span> defaultValue(result: optional!)</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">}</div></div></blockquote><br class=""><div class="">This will always throw an exception as you are force unwrapping the optional in both branches of the ternary, i.e. also in the branch which is used when it is nil.</div><div class=""><br class=""></div><div class="">-Thorsten </div></div></div></blockquote></div><br class=""></body></html>