<!--
{
  "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" : "CreateMLComponents",
  "identifier" : "/documentation/CreateMLComponents/SlidingWindows/index(_:offsetBy:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents14SlidingWindowsV5index_8offsetByS2i_SitF"
  },
  "title" : "index(_:offsetBy:)"
}
-->

# index(_:offsetBy:)

Returns an index that is the specified distance from the given index.

```
func index(_ i: Int, offsetBy distance: Int) -> Int
```

## Parameters

`i`

A valid index of the collection.

`distance`

The distance to offset `i`.

## Return Value

An index offset by `distance` from the index `i`.

## Discussion

The value passed as `distance` must not offset `i` beyond the bounds of the collection.

---

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)