<div dir="ltr">Currently, force unwraping .None/nil optional results in a runtime error. I suggest to put operator/method which will allow the optional unwrap to result in exception. For example:<br><span style="font-family:monospace,monospace"><br>enum OptionalError: ErrorType {<br> case NoValue(String)<br>}<br><br>extension Optional {<br> func unwrap(@autoclosure reason: () -> String = "No value found") throws -> Wrapped {<br> if let val = self {<br> return val<br> } else {<br> throw OptionalError.NoValue(reason())<br> }<br> }<br>}</span><br clear="all"><div><br></div><div>Alternatively we could put a postfix operator like !!.<br></div><div><br>-- <br><div class="gmail_signature">Best Regards,<br>Nikolay Petrov<br></div>
</div></div>