I want to filter an array of objects.
struct Person {
let name: String
}
let p1 = Person(name:"test1")
let p2 = Person(name:"test1")
let p3 = Person(name:"test2")
let persons = [p1, p2, p3]
How i can filter the persons
list and return the persons which have the same name?
I have tried to use a filter method, but I can't apply it with multiple arguments.
I am looking for a functional solution like a filter
or a reduce
function and not looping over the list.