swap

This block is part of the array group and was last modified in core v10.4.28.

swap v10.4.28

In pins 3
  • 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.

Out pins 1
  • 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: with values feeds the array pin; the array out pin feeds length.

Studio canvas example for the swap block: typical wiring for swap.

Version history

Introduced in v10.4.28.


Back to array Return to the main group to view all sub-groups Back to array Return to the group to view all blocks within this group