Protocols

The following protocols are available globally.

  • A type that can be expressed and utilized as a semantic version conforming to SemVer.

    Additionally to the ranking and comparison rules if their version core identifiers are nil they will be treated as 0.

    let versionOne = Version(1, 0, 0)
    let versionTwo = Version(1)
    
    versionOne == versionTwo // <- this statement is `true`
    

    You can choose between a loosly or strictly comparison considering if you want to include the build-meta-data of versions when comparing:

    let versionOne = Version(1, 0, 0, [.alpha])
    let versionTwo = Version(1, 0, 0, [.alpha], ["exp"])
    
    versionOne == versionTwo // `true`
    versionOne === versionTwo // `false`
    

    Remark

    See semver.org for detailed information.
    See more

    Declaration

    Swift

    public protocol SemanticVersionComparable : Comparable, Hashable