November 2016
Intermediate to advanced
480 pages
14h 42m
English
The first function you wrote in this chapter was printGreeting(). It took no arguments and returned nothing. Or, did it?
It turns out that functions that do not explicitly return something actually do still have a return. They return something called Void. This return is inserted into the code for you by the compiler.
So, while you wrote printGreeting() like this:
func printGreeting() {
print("Hello, playground.")
}
The compiler actually added something like this to your code:
func printGreeting() -> Void {
print("Hello, playground.")
}
In other words, it added a return value of Void for you. Just what is Void? Go ahead and make printGreeting return Void, as shown above. Command-click on the word ...
Read now
Unlock full access