Will it work

This commit is contained in:
cdricms
2025-09-13 23:24:55 +02:00
parent c28024b17d
commit 551177803d

View File

@@ -412,6 +412,16 @@ public struct UnitValue<ValueType: ConvertibleToDouble>:
return (lhs.value * rhs.value)[lhs.unit]
}
public func operation(
value: any ConvertibleToDouble,
op: (
_ lhs:
any ConvertibleToDouble, _ rhs: any ConvertibleToDouble
) -> any ConvertibleToDouble
) -> UnitValue<Double> {
op(self.value, value).doubleValue[self.unit]
}
// MARK: - Subscripts for UnitValue
/// Allows converting the UnitValue to another Unit using subscript syntax.
/// Example: `tenKilos[.pound]`