Now, it is time to get into an enjoyable part of programming and learn how to write functions. Functions are self-contained pieces of code that you want to run on something. In Swift 3, Apple made a change to how you should write functions. All of the functions we will write in this chapter will perform an action (think of verbs). Let's create a simple function called greet():

This example is a basic function with a print statement in it. In programming, functions do not run until you call them. We call a function by merely calling its name. So, let's call greet, as follows:
greet()
Once we add this to the code, this is what we'll see on screen:

That's it! We just created our first function and called it. However, functions can do so much more. We can add what is called a parameter to a function. A parameter allows us to accept data types inside...