var string1 = ["A", "B", "C"] var string2 = ["B"]
how to get the following result? Thanks so much!
var result = ["A","C"]
CodePudding user response:
You can use a filter
to filter out any elements in string1
that are contained in string2
:
let result = string1.filter { !string2.contains($0) }