SE-0380: `if` and `switch` expressions

Should do statement be considered in this pitch as well (mentioned in the "alternatives considered" section for starters) or do you think it is totally out of scope and deserves its own pitch?

let x = do { // type inferred
    return try foo()
} catch {
    return bar(error)
}

// ditto with return statement syntax optimization:

let x = do { // type inferred
    try foo()
} catch {
    bar(error)
}

instead of:

let x: T // explicit type annotation

do {
    x = try foo()
} catch {
    x = bar(error)
}
5 Likes