Swap 2 elements in array

 Problem

I have an array and want to swap two of its elements, by index.



 Recipe


// Initialize the Array
var arr = ["one", "two", "three", "four", "five"]

// Swap elements at index: 2 and 3

swap(&arr[2], &arr[3])
print(arr)

				


 Playground