<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/Scene/AnchorCollection/endIndex",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation5SceneC16AnchorCollectionV8endIndexSivp"
  },
  "title" : "endIndex"
}
-->

# endIndex

The position one greater than the last valid subscript argument.

```
@MainActor @preconcurrency var endIndex: Int { get }
```

## Discussion

When you need a range that includes the last element of an array,
use the half-open range operator (`..<`) with
[`endIndex`](/documentation/RealityKit/Scene/AnchorCollection/endIndex). The `..<` operator creates a
range that doesn’t include the upper bound, so it’s safe to
use with [`endIndex`](/documentation/RealityKit/Scene/AnchorCollection/endIndex).

If the array is empty, [`endIndex`](/documentation/RealityKit/Scene/AnchorCollection/endIndex) is equal
to [`startIndex`](/documentation/RealityKit/Scene/AnchorCollection/startIndex).

---

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)