I have two arrays
let badContents = ["b1", "b2"]
let things: [Thing] = ...
where a Thing has its own contents, like this
print(things[0].contents)
// ["g1", "b1", "b2"]
I wanted to do something like the below, where I would get an array of type Thing
whose elements had contents that did not overlap with another array, badContents
func filteredThings() -> [Thing] {
return things.filter({ (thing) -> Bool in {
return // thing.contents and badContents do not share any elements
}()
})
}
Thus, I would get a result like this
let things = [Thing(name: "1", contents: ["g1", "b2"), Thing(name: "2", contents: ["g1", "g2"])]
let goodThings = filteredThings() // removes Thing named "1" because its contents contain "b2"
for goodThing in goodThings {
print(goodThing.name)
// "2"
}