BidirectionalCollection

public extension BidirectionalCollection
  • SwifterSwift: Returns the element at the specified position. If offset is negative, the nth element from the end will be returned where n is the result of abs(distance).

       let arr = [1, 2, 3, 4, 5]
       arr[offset: 1] -> 2
       arr[offset: -2] -> 4
    

    Declaration

    Swift

    subscript(offset distance: Int) -> Element { get }

    Parameters

    distance

    The distance to offset.