[Pitch] Last expression as return value

Omission isn't prohibition. But while this pitch might seem orthogonal to the the problem, it's actually just an addressing of the subset of the problem.

This pitch doesn't offer anything that IICEs don't already offer, and doesn't match their control flow options. I don't care either way about last expression as return value, but it doesn't fix do/catches that need to return multiple expressions like the then pitch would.

IICE:

let value = {
  print("something")
  guard condition else { return 1 }
  print("something else")
  return 2
} ()

The only option, with this pitch, is …OMG indentation we can't have indentation!

let value = do {
  print("something")
  if !condition { 1 } else {
    print("something else")
    2
  }
}
2 Likes