<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/AnyBidirectionalCollection/subscript(_:)-93ijp",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Subscript",
  "symbol" : {
    "kind" : "Instance Subscript",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SlsEys18DiscontiguousSliceVyxGs8RangeSetVy5IndexQzGcip::SYNTHESIZED::s:s26AnyBidirectionalCollectionV"
  },
  "title" : "subscript(_:)"
}
-->

# subscript(_:)

Accesses a view of this collection with the elements at the given
indices.

```
subscript(subranges: RangeSet<Self.Index>) -> DiscontiguousSlice<Self> { get }
```

## Parameters

`subranges`

The indices of the elements to retrieve from this
collection.

## Return Value

A collection of the elements at the positions in `subranges`.

## Overview> Complexity: O(1)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)