Measurements and units
With Swift 3's release, the Foundation team is releasing a new API to make handling measurements easier for developers. By allowing developers to create measurements from common built-in units (or create custom ones), convert between units and format them for display. We will cover each of the main areas of the Measurement API to get you ready to use them in your projects.
Measurement
A measurement is composed of a unit and a value. A unit is a class that contains a single property to hold a symbol. We will come back to units in a moment. For now, let's focus on what you can do with a measurement.
public struct Measurement<UnitType : Unit> : ReferenceConvertible, Comparable, Equatable { public typealias ReferenceType = NSMeasurement /// The unit component of the `Measurement`. public let unit: UnitType /// The value component of the `Measurement`. public var value: Double /// Create a `Measurement` given a specified...