I have 2 Arrays. Say, array1 = [1,2,3,4,5] and array2 = [2,3]. How could I check in swift if array1 contains at least one item from
array1 = [1,2,3,4,5]
array2 = [2,3]
array1
An alternative way would be using Sets:
let array1 = [1,2,3,4,5] let array2 = [2,3] let set1 = Set(array1) let intersect = set1.intersect(array2) if !intersect.isEmpty { // do something with the intersecting elements }