Throw inside a do block and catch it back in Swift? Yes

Lazy forks, it's just simple topic, but I did the experiment for you:

enum SomeError: Error {
    case notBig
    case veryBig
}
func someErrorFucntion() {
    do {
        throw SomeError.veryBig
    } catch {
        print(error.localizedDescription)
    }
}

someErrorFucntion() // And it will print veryBig!!

Subscribe to TechRD.in

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe