4

What does Void in Swift 4 mean? If I have a function to fulfill, as follows:

func someFunc() -> Promise<Void> {
    fulfill()
}

an error shows, and it only works if:

fulfill(Void())

Note. Swift 3 supported:

fulfill()

I am using Swift 4, but can someone help explain why Void in Swift 4 has a constructor?

Paulo Mattos
  • 18,845
  • 10
  • 77
  • 85
lePapa
  • 357
  • 2
  • 11
  • FYI this is probably a Swift 4 bug (well, some on Swift team have told me it's intended, but I expect it will be “fixed” due to this kind of confusion eventually). Also you need not specify `Void`, `fulfill(())` will work. – mxcl Nov 27 '17 at 20:58

1 Answers1

6

Void is defined as an empty tuple in Swift. You can take a look swift-void.

Community
  • 1
  • 1
Enea Dume
  • 3,014
  • 3
  • 21
  • 36