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")



Find answers here

Hi there! Ask Us a Question We are ready to help