---
title: "swapAt(_:_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/unsafemutablerawbufferpointer/swapat(_:_:)"
---

# swapAt(_:_:)

Exchanges the byte values at the specified indices in this buffer’s memory.

## Declaration

```swift
func swapAt(_ i: Int, _ j: Int)
```

## Parameters

- `i`: The index of the first byte to swap.
- `j`: The index of the second byte to swap.

## Discussion

Discussion Both parameters must be valid indices of the buffer, and not equal to endIndex. Passing the same index as both i and j has no effect.
