Last active
September 6, 2017 20:34
-
-
Save cgoldsby/3a05ec08da929ce0a5bd3fed0bc705c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func myFunction() { | |
return { print("All done") }() // Inline closure | |
} | |
func myFunction() { | |
return () // () -> Void | |
} | |
func myFunction() { | |
return Void() // Compiles! | |
} | |
// MARK: - Does not compile | |
func myFunction() { | |
return Void // Does not compile since Void is a type (alias). Even though Void = () | |
} | |
func myFunction() { | |
return // Function must be on the same line to compile | |
print("Does not compile") // warning: expression following 'return' is treated as an argument of the 'return' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment