<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/ReversedCollection/Index/init(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s18ReversedCollectionV5IndexVyADyx_GACQzcfc"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates a new index into a reversed collection for the position before
the specified index.

```
init(_ base: Base.Index)
```

## Parameters

`base`

The position after the element to create an index for.

## Discussion

When you create an index into a reversed collection using `base`, an
index from the underlying collection, the resulting index is the
position of the element *before* the element referenced by `base`. The
following example creates a new `ReversedIndex` from the index of the
`"a"` character in a string’s character view.

```
let name = "Horatio"
let aIndex = name.firstIndex(of: "a")!
// name[aIndex] == "a"

let reversedName = name.reversed()
let i = ReversedCollection<String>.Index(aIndex)
// reversedName[i] == "r"
```

The element at the position created using `ReversedIndex<...>(aIndex)` is
`"r"`, the character before `"a"` in the `name` string.

---

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)