Measurement
data class Measurement<out UnitType : Dimension>(val value: Double, val unit: UnitType) : Comparable<Measurement<UnitType>>
A Measurement holds a value in a specific unit.
Parameters
Unit Type
The type of unit (e.g., UnitTemperature, UnitSpeed).
value
The numerical value of the measurement.
unit
The unit of the measurement.
Properties
Functions
Link copied to clipboard
Compares this measurement to another measurement, enabling sorting and range operations. The other parameter uses in variance. This allows a MeasurementComparable contract.
Link copied to clipboard
Converts this measurement to a different unit of the same dimension. The to parameter is marked with @UnsafeVariance because it's in an "in" position, but we know our usage is safe as we only read from it for conversion.
Link copied to clipboard