In Swift 4, tuples are handled more rigorously than ever.
This type of closure: (Void)->Void means a closure that
- takes one argument whose type is
Void - returns
Void , which means no value
So try the following:
Pass a value of type Void to the closure. (An empty tuple () is the only instance of Void .)
completion?(())
Or else:
Change the type of completion parameter.
func openAnimation(_ completion: (() -> Void)?) { //... }
Remember that the two types (Void)->Void and ()->Void are different even in Swift 3. Thus, the latter would be appropriate if you intend to represent the type of closure without arguments.
This change is part of SE-0029 Remove the implicit tuple character behavior from function applications , which is said to be implemented in Swift 3, but it seems that Swift 3 did not fully implement it.
Here I will show you a simplified verification code that you can verify on the playground.
import Foundation
Ooper
source share