What is a Measure and how does it work?
masterA Measure is an immutable value associated with a unit (e.g., 5 meters) within a specific unit system (e.g., SI).
Key Characteristics:
- Immutability: Any operation on a
Measurereturns a newMeasureinstance. - Type Safety: The
Measureclass uses two type parameters:B(the basis for the unit system) andU(the type of the unit). - Internal Representation: All measures are represented internally in terms of their base units (e.g., meters for length). This allows for seamless arithmetic between different units of the same dimension without manual conversion.
- Numeric Type: By default,
Measureworks with JavaScriptnumbertypes.