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 ...