Generic Structure

Measurement

A numeric quantity labeled with a unit of measure, with support for unit conversion and unit-aware calculations.

Overview

Measurements support a large set of operators, including `+`, `-`, `*`, `/`, and a full set of comparison operators.

Topics

Creating a Measurement

`init(value: Double, unit: UnitType)`

Create a `Measurement` given a specified value and unit.

Accessing the Value and Units

`let unit: UnitType`

The unit component of the `Measurement`.

`var value: Double`

The value component of the `Measurement`.

Converting to Other Units

`func convert(to: UnitType)`

Converts the measurement to the specified unit.

`func converted(to: UnitType) -> Measurement<UnitType>`

Returns a new measurement created by converting to the specified unit.

Operating on a Measurement

`static func != (Measurement<UnitType>, Measurement<UnitType>) -> Bool`

Returns a Boolean value indicating whether two values are not equal.

`static func ..< (Measurement<UnitType>) -> PartialRangeUpTo<Measurement<UnitType>>`

Returns a partial range up to, but not including, its upper bound.

`static func <= (Measurement<UnitType>, Measurement<UnitType>) -> Bool`

Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.

`static func > (Measurement<UnitType>, Measurement<UnitType>) -> Bool`

Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.

`static func >= (Measurement<UnitType>, Measurement<UnitType>) -> Bool`

Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.

Describing a Measurement

`var description: String`

A textual description of the measurement.

`var debugDescription: String`

A textual description of the measurement suitable for debugging.

`var customMirror: Mirror`

A mirror that reflects the date interval.

`var hashValue: Int`

The computed hash value for the date interval.

Using Reference Types

`class NSMeasurement`

An object representing a numeric quantity with a unit of measure that bridges to `Measurement`; use `NSMeasurement` when you need reference semantics or other Foundation-specific behavior.

`typealias Measurement.ReferenceType`

An alias for this value type's equivalent reference type.

Instance Methods

`class Unit`
`class Dimension`