Skip to content

Instantly share code, notes, and snippets.

@jeremiegirault
Created June 9, 2017 09:23
Show Gist options
  • Save jeremiegirault/43822db33c0c5aa447c99fc3e3b0be4a to your computer and use it in GitHub Desktop.
Save jeremiegirault/43822db33c0c5aa447c99fc3e3b0be4a to your computer and use it in GitHub Desktop.
// The sad state of tuples in swift 4
func test() {
return () // why is it not mandatory ?
}
// func test() -> Void {} // error: invalid redeclaration of 'test()' why is it a redefinition ?
/*
The problem is that Void in swift is not the "Absence" of a parameter but the type of the empty tuple
We should change the definition to:
*/
typealias Unit = ()
let unit: Unit = ()
// Void should not be considered as empty tuple but should be an intrinsic and always be flattened
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment