The syntax that's used to define a function in Swift is very flexible. This flexibility makes it easy for us to define simple C-style functions, or more complex functions, with local and external parameter names, which we will see later in this chapter. Let's look at some examples of how to define functions. The following example accepts one parameter and does not return any value back to the code that called it:
func sayHello(name: String) -> Void { let retString = "Hello " + name print(retString) }
In the preceding example, we defined a function named sayHello() that accepted one parameter, named name. Inside the function, we printed out a greeting to the name of the person. Once the code within the function is executed, the function exits, and control is returned back to the code that called it. Rather than...