BidirectionalCollection
public extension BidirectionalCollection
-
SwifterSwift: Returns the element at the specified position. If offset is negative, the
n
th element from the end will be returned wheren
is the result ofabs(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.