Swap 2 elements in array


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


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

// Swap elements at index: 2 and 3

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


Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)