Quiz · Errors · lesson 5 of 7
Quiz — try?
Question 1 of 2
What does the program print?
enum ParseError: Error {
case badFormat
}
func parse(_ text: String) throws -> Int {
guard let n = Int(text) else {
throw ParseError.badFormat
}
return n
}
let a = (try? parse("8")) ?? -1
let b = (try? parse("8x")) ?? -1
print(a, b)