---
title: "formIndex(before:)"
framework: Swift
role: symbol
role_heading: Instance Method
platforms: [iOS 27.0+, iPadOS 27.0+, Mac Catalyst 27.0+, macOS 27.0+, tvOS 27.0+, visionOS 27.0+, watchOS 27.0+]
path: "swift/uniquearray/formindex(before:)"
---

# formIndex(before:)

Replaces the given index with its predecessor.

## Declaration

```swift
func formIndex(before index: inout Int)
```

## Parameters

- `index`: A valid index of the array. i must be greater than startIndex.

## Discussion

Discussion note: To improve performance, this method does not validate that the given index is valid before decrementing it. Index validation is deferred until the resulting index is used to access an element. This optimization may be removed in future versions; do not rely on it. note: O(1)
