8

I keep getting an error from swift playgrounds that it can't find the "missing argument for parameter 'closure' in call."

func someFunc(closure: () -> (), closure2: () -> ()) {
    closure()
    closure2()
}

someFunc() {
    print("Calling from closure()")
} closure2: {
    print("Calling from closure2()")
}
1
  • Excellent! Your example is better than the official one in The Swift Programming Language for a beginner. Commented Dec 18, 2021 at 9:15

1 Answer 1

10

Multiple trailing closures are a new Swift 5.3 beta feature. Your code compiles and runs correctly in Xcode 12 beta using Swift 5.3 beta, as shown in this screen shot:

enter image description here

It is probable that the environment in which you are running does not have a Swift 5.3 beta compiler.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.