Measurement

extension Measurement
extension Measurement where UnitType: Dimension
  • tt

    Returns a decorator that provides additional methods.

    Using a decorator is a convenient way of extending Measurement while mitigating the risk of conflicting with extensions from other libraries or Apple. Extending standard structures like Measurement with properties like var meters is convenient:

    • it avoids extracting value without explicit conversion to a certain unit
    • it simplifies getting a value from an optional Measurement

    Typical use cases for MeasurementDecorator are:

    • extracting value from a value representing a unit of measure: let optionalDistanceInMeters = distance?.tt.meters
    • performing computations on values representing units of measure: cumulativeDistance += anotherDistance.tt
    • comparing values representing units of measure: if delay < .tt.seconds(5) {}
    • combining value extraction and typecast: let intValue = distance.tt.intValue(in: .meters)

    Declaration

    Swift

    public var tt: MeasurementDecorator<UnitType> { get }
  • tt

    Returns the type of decorator that provides additional static methods. A decorator is a convenient way of extending Measurement while mitigating the risk of conflicting with extensions from other libraries or Apple.

    Declaration

    Swift

    public static var tt: MeasurementDecorator<UnitType>.Type { get }

Available where UnitType: Dimension

  • It should not conflict with other libs extensions since the right part is a decorator.

    Declaration

    Swift

    public static func += (left: inout Measurement<UnitType>, right: MeasurementDecorator<UnitType>)
  • It should not conflict with other libs extensions since the right part is a decorator.

    Declaration

    Swift

    public static func -= (left: inout Measurement<UnitType>, right: MeasurementDecorator<UnitType>)