---
title: "index(_:offsetBy:)"
framework: createmlcomponents
role: symbol
role_heading: Instance Method
path: "createmlcomponents/slidingwindows/index(_:offsetby:)"
---

# index(_:offsetBy:)

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

## Declaration

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

## Parameters

- `i`: A valid index of the collection.
- `distance`: The distance to offset i.

## Return Value

Return Value An index offset by distance from the index i.

## Discussion

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

## See Also

### Getting the index

- [index(after:)](createmlcomponents/slidingwindows/index(after:).md)
- [index(before:)](createmlcomponents/slidingwindows/index(before:).md)
