April 2017
Intermediate to advanced
316 pages
9h 33m
English
We can use try! if we know that there is no way a method call will fail, or if it fails then our code will be broken and we should crash the application.
When we use the try! keyword, it disables error propagation and we do not need to have do and catch around our code block because we promise it will never fail! It is a big promise that we should avoid.
In case we have to bypass error handling such as checking whether a database file exists, we can do the following:
let result = try! readFile(path: "path/to")
Read now
Unlock full access