convertTo method

Quantity<K> convertTo(
  1. Unit<K> anotherUnit
)

Returns a new Quantity converted to another unit.

Implementation

Quantity<K> convertTo(Unit<K> anotherUnit) {
  double converted;
  if (anotherUnit == unit) {
    converted = amount;
  } else {
    converted = unit.quantityConverterTo(anotherUnit)(amount);
  }
  return Quantity<K>(unit: anotherUnit, amount: converted);
}