Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created Jan 17, 2021
Embed
What would you like to do?
class UnitBanana: Dimension {
override static func baseUnit() -> Self {
return UnitBanana.banana as! Self
}
static let banana = UnitBanana(symbol: "bana", converter: UnitConverterLinear(coefficient: 1.0))
}
let formatter = MeasurementFormatter()
formatter.unitOptions = .providedUnit
print(formatter.string(from: Measurement(value: 2, unit: UnitBanana.banana)))
// 2 bana
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment