[swift-evolution] Proposal: Define and call a named nested function in one step.

Amir Michail a.michail at me.com
Wed Feb 17 09:58:28 CST 2016


Writing nested functions with meaningful names is a good way to document the code while reducing the complexity of the function containing them.

This proposal concerns nested functions that are defined just before they are called (a common thing to do to avoid passing parameters to the nested function):

func f() {
  …
  func g() {
    ...
  }
  g()
  ...
}

With this proposal, you would be able to just write:

func f() {
  …
  call func g() {
    ...
  }
  ...
}



More information about the swift-evolution mailing list