From the Swift Evolution common proposals document:
- Infer
return
for omittedguard
body: It has been proposed many times to allow omission of theguard
body for the sake of brevity. However, a core principle of Swift is to make control flow explicit and visible. For example, thetry
keyword exists solely to indicate to the human reader where thrown errors can happen. Implicit returns would violate this principle, favoring terseness over clarity in a way that isn't typical of Swift. Furthermore, there are many ways of exiting the scope other thanreturn
(loops may wantbreak
orcontinue
), and not every function has an obvious default value to return.