-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Swift 4 Programming Cookbook

A tuple is a combination of two or more values that can be treated as one. If you have ever wished you could return more than one value from a function or method, you should find tuples very interesting.
Create a new playground and add the following statement:
import Foundation
This example uses one function from Foundation. We will delve into Foundation in more detail in Chapter 5, Beyond the Standard Library, but for now, we just need to import it.
Let's say that we are building an app that pulls together movie ratings from multiple sources and presents them together to help the user decide which movie to see. These sources may use different rating systems, for instance, the number of stars out of 5, points out of 10, or a rating as a percentage, and so on. We want to normalize the ratings before we can display them side by side; this will allow them to be compared directly. We want all the ratings to be represented as a number of...