[Pitch] Last expression as return value

I still believe this is a great feature provided it is disabled for discardable results:

    func cook(vegetable: Vegetable) -> Vegetable {
        print("Bzzzz")
        vegetable.cook() // ❌Error: discardableResult functions need explicit return!
    }
    func cook2(vegetable: Vegetable) -> Vegetable {
        print("Bzzzz")
        Vegetable() // ✅ fine
    }

thus fixing the regression mentioned in the headline post and making it less non-obvious. This feature naturally promotes "single expression rule" to "last expression rule" (single line is the last line as well) thus making the language conceptually simpler.

Yeha, soon to be the all time winner :person_facepalming:

1 Like