Will it work
This commit is contained in:
@@ -412,6 +412,16 @@ public struct UnitValue<ValueType: ConvertibleToDouble>:
|
|||||||
return (lhs.value * rhs.value)[lhs.unit]
|
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
|
// MARK: - Subscripts for UnitValue
|
||||||
/// Allows converting the UnitValue to another Unit using subscript syntax.
|
/// Allows converting the UnitValue to another Unit using subscript syntax.
|
||||||
/// Example: `tenKilos[.pound]`
|
/// Example: `tenKilos[.pound]`
|
||||||
|
|||||||
Reference in New Issue
Block a user