# Index

`import { Index } from "destack:ops";`

Interface for index access `a[i]`.

`a[i]` projects the place returned by `a.index(i)`.

The index type `I` can be any type (int, string, tuple, range, etc.).

```ds title="Index"
export newtype interface Index<I, const A: Access = "readonly"> {
    Output;
    Missing = never;
    index<const L: Lifetime>(key: I): WithLifetime<WithAccess<&this.Output, A>, L> | this.Missing;
}
```

[language/library/src/ops/subscript.ds:9:21](https://github.com/destack-sh/destack/blob/main/language/library/src/ops/subscript.ds#L9-L21)

## Members

### `Output`

The indexed output type.

### `Missing = never`

The result when no indexed value exists.

### `index<const L: Lifetime>(key: I): WithLifetime<WithAccess<&this.Output, A>, L> | this.Missing`

Borrow the value at `key`.
