[Pitch] Last expression as return value

How does this interact with result builders?

e.g. this code:

var body: some View {
    Text("Foo")
    Text("Bar")
}

is currently interpreted something like

var body: some View {
    Group {
        Text("Foo")
        Text("Bar")
    }
}

However, this is also valid:

var body: some View {
    Text("Foo")
    return Text("Bar")
}

The latter interpretation is obviously less common, but still out in the wild, and would still require an explicit final return.

9 Likes