() is both a type (and Void is a type alias for an empty tuple type) and the only value of this type. So
let x = ()
defines x as a property of a constant of type () (aka Void ) with a value of () .
Equivalent statements would be
let x:() = () let x:Void = ()
but not
let x = Void // error: expected member name or constructor call after type name
because Void is a type, but not a value.
When defining function types without parameters and / or without a return value, it seems that there is agreement to use () for an empty parameter list, and Void without a return value. This can be seen, for example, in UIKit completion handlers or for execution blocks presented in GCD Send Queues, for example
func sync(execute block: () -> Void)
source share