Numbers or numeric values, and dates, are one of the most common things a programmer has to deal with daily.
In this chapter, we’ll explore different ways that we can handle numbers in Swift, convert to and from different units, or make use of all of Swift’s mathematical capabilities and also see how we can make our life easier when working with date objects.
10.1 Calculate average of elements in array
Problem
I want to calculate the average of all elements in a given number array.
Solution
Then, we calculate the average.