Array1 = [1,2,3]
Array 2 = [2,4,5,7]
I have above two arrays , I need to find whether any value in Array1 is in another array (Array 2) .
If Array1(value) matches Array2(value){
// BINGO , you have integer value 2 in second array , i.e 2 is common in two arrays
}
I know contains() which checks if array contains particular value or not. But it would make more loops.
var elements = [1,2,3,4,5]
if elements.contains(5) {
print("yes")
}
P.S:: I was searching if there is any swift function for this. I want to limit my loops for searching common values is two arrays.
Any help would be appreciated.