Quiz · Errors · lesson 2 of 7
Quiz — throw
Question 1 of 2
What does the program print (lines separated by spaces)?
enum TextError: Error { case empty }
func letters(in text: String) throws -> Int {
if text.isEmpty { throw TextError.empty }
return text.count
}
do {
print(try letters(in: "ab"))
print(try letters(in: ""))
print("end")
} catch {
print("error")
}