---
title: "swap · RUAL Documentation"
description: "RUAL array block."
canonical: https://docs.rual.nl/block-types/array/array_swap
language: en
---

# swap

This block is part of the [`array`](https://docs.rual.nl/block-types/array) group and was last modified in core [`v10.4.28`](https://docs.rual.nl/core-versions/100428).

- array required `array` The array in which items will be swapped.

- Index Item #1 required `number` The index of the first item to be swapped.

- Index Item #2 required `number` The index of the second item to be swapped.

- Array `array` The array after swapping the specified items.

Returns a COPY of the array with the elements at the two zero-based indexes exchanged; the input is not mutated. If EITHER index is negative or out of range, the array passes through unchanged.

A typical wiring for [swap](https://docs.rual.nl/block-types/array/array_swap): [with values](https://docs.rual.nl/block-types/array/array_of_values) feeds the `array` pin; the `array` out pin feeds [length](https://docs.rual.nl/block-types/array/array_length).

![Studio canvas example for the swap block: typical wiring for swap.](https://docs.rual.nl/canvas-examples/array_swap.png)

### Version history

Introduced in [`v10.4.28`](https://docs.rual.nl/core-versions/100428).
