[Pitch] if and switch expressions

One thing that I think makes me uneasy about the final-expression thing is that this code is has been valid and common Swift for a few years:

VStack {
    if someCondition {
        producesSomeView()
        producesAnotherView()
    } else {
        aDifferentView()
    }
}

and it is to be read in a fundamentally different way than this very similar looking newly-proposed code:

var backgroundColor: Color {
    if someCondition {
        vaguelyNamedFunctionThatMightReturnAValue()
        otherFunctionDoesWhoKnowsWhat()
        theOneAndOnlyReturnValue()
    } else {
        theOtherReturnValue()
    }
}
9 Likes