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()")
}
Diego Salas
  • 153
  • 1
  • 7
  • Excellent! Your example is better than the official one in _The Swift Programming Language_ for a beginner. – bfhaha Dec 18 '21 at 09:15

1 Answers1

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.

matt
  • 515,959
  • 87
  • 875
  • 1,141