[swift-evolution] Proposal: optionally define nested functions elsewhere
Amir Michail
amichail at gmail.com
Sun Feb 7 08:32:19 CST 2016
The problem with nested functions is that they can make the function containing them very long and hard to read.
So the idea is to separate the body of a nested function from where it is declared.
For example:
func f() {
var x:Int
func g(y:String) {
print(“x=\(x), y=\(y)")
}
...
}
could be refactored as:
func f() {
var x:Int
func g(y:String) // function body elsewhere to avoid clutter in f
...
}
func f().g(y:String) {
print(“x=\(x), y=\(y)")
}
More information about the swift-evolution
mailing list