We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aa85fc7 commit f207504Copy full SHA for f207504
1 file changed
Sources/Units/Unit/Unit.swift
@@ -37,6 +37,15 @@ public struct Unit {
37
}
38
39
40
+ /// Retrieve a unit by name. This name is compared to the global registry and the relevant unit is initialized.
41
+ /// Only defined units are returned - complex unit name equations are not supported.
42
+ ///
43
+ /// - Parameter symbol: A string name of the unit to retrieve. This cannot be a complex equation of names.
44
+ public init(fromName name: String) throws {
45
+ let definedUnit = try Registry.instance.getUnit(byName: name)
46
+ self.init(definedBy: definedUnit)
47
+ }
48
+
49
/// Create a unit from the defined unit object.
50
/// - Parameter definedBy: A defined unit to wrap
51
internal init(definedBy: DefinedUnit) {
0 commit comments