I know that this answer can complicate the situation and that you can use a filter, but ... do you consider using Setsinstead Arrays?
setA, setB, setA setB .
.
. , , , .
:
( ):
, , .
... - , .
... Email Hashable:
struct Email {
let name: String
let email: String
}
extension Email: Hashable {
var hashValue: Int {
return "\(name)\(email)".hashValue
}
static func ==(lhs: Email, rhs: Email) -> Bool {
return lhs.name == rhs.name && lhs.email == rhs.email
}
}
:
let arrayA = [Email(name: "name1", email: "email1"), Email(name: "name2", email: "email2")]
let arrayB = [Email(name: "name1", email: "email1"), Email(name: "name3", email: "email3")]
let setA = Set(arrayA)
let setB = Set(arrayB)
let inBothAAndB = setA.intersection(setB)
let inAButNotB = setA.subtracting(setB)
let inBButNotA = setB.subtracting(setA)
... , , , ( , ), ... , :)
, .