RangeProtocol

public protocol RangeProtocol

Unifying interface for Range and ClosedRange types.

Available where Bound: SignedNumeric

  • length Extension method

    Declaration

    Swift

    public var length: Bound { get }

    Return Value

    The length of this range (upperBound - lowerBound).

Available where Bound: Numeric

  • shifted(by:) Extension method

    Declaration

    Swift

    public func shifted(by amount: Bound) -> Self

    Return Value

    A new range equal to this range with bounds shifted by the given amount.