If I understand this pitch correctly, it would allow me avoid writing this code:
let data: Data
let response: URLResponse
do {
(data, response) = try await URLSession.shared.data(for: request)
} catch {
throw RequestError.failedToLoadData(error)
}
And instead I could write this much more readable and convenient code:
let (data, response) = do {
try await URLSession.shared.data(for: request)
} catch {
throw RequestError.failedToLoadData(error)
}
Do I understand that right?
For this aspect alone, I'm supporting this pitch. I'm not so sure about the introduction of a then
keyword though, I don't find it very intuitive on first read of the proposal. The aspect I'm most interested in is the allowance of do-expressions. It might be added in a much narrower proposal. I pitched another change here to solve the same problem: