9.9 Returning Multiple Results from a Function
A function can return multiple result values by wrapping those results in a tuple. The following function takes as a parameter a measurement value in inches. The function converts this value into yards, centimeters and meters, returning all three results within a single tuple instance:
func sizeConverter(_ length: Float) -> (yards: Float, centimeters: Float,
meters: Float) {
let yards = length * 0.0277778
let centimeters = length * 2.54
let meters = length * 0.0254
return (yards, centimeters, meters)
}
The return type for the function indicates that the function...