Check if 2 arrays are equal


I have two arrays and want to check if they are equal (if it's the same array, with all elements in the same order).


// Initialize the Arrays
let a1 = [1, 2, 3]
let a2 = [2, 3, 1]
// Check if they are the same

if a1==a2 {
    print("S1 is the same as S2")
else {
    print("S1 is not the same as S2")


Heard the news?

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