Перейти к содержимому
Тест · Ошибки · урок 2 из 7

Тест — throw

Вопрос 1 из 2

Что выведет программа (строки через пробел)?

SWIFT
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")
}