Reputation: 18581
Recursive functions currently cause compile-time error in xcode projects using swift, but work just fine in a playground. In the release notes of Xcode 6 beta 4 :
Nested functions that recursively reference themselves or other functions nested in the same outer function crash the compiler. (11266246) For example:
func foo() { func bar() { bar() } func zim() { zang() } func zang() { zim() } }
Workaround: Move recursive functions to the outer type or module context
What is meant by Move recursive functions to the outer type or module context?
Upvotes: 0
Views: 578
Reputation: 94723
It means that you should declare the function outside of the other function:
func bar() { bar() }
func zim() { zang() }
func zang() { zim() }
func foo() {
}
Upvotes: 1