Swiftui Check If Array1 Contains At Least One Item From

[Solved] Swiftui Check If Array1 Contains At Least One Item From | Vb - Code Explorer | yomemimo.com
Question : swiftui check if array1 contains at least one item from array2

Answered by : tony-sacco

let array1 = [2, 3, 4, 5]
let array2 = [20, 15, 2, 7]
// this is just shorthand for array1.contains(where: { array2.contains($0) })
if array1.contains(where: array2.contains) { print("Array 1 and array 2 share at least one common element")
} else { print("Array 1 doesn't contains any elements from array 2")
}

Source : https://stackoverflow.com/questions/37299385/swift-determine-if-array1-contains-at-least-one-object-from-array2 | Last Update : Mon, 05 Dec 22

Answers related to swiftui check if array1 contains at least one item from array2

Code Explorer Popular Question For Vb