i have objects
var person1 = Person()
person1.name = \"Joe\"
person1.lastName = \"Doe\"
person1.age = 21
var person2 = Person()
person2.name = \"Julia\"
person2
Here is a pretty simple way to do what you need:
let result = array
.flatMap { $0 }
.first(where: { $0.name == "Masha" })
First you have to make your array flatted and then you can just get the first element from the array that satisfies the given predicate (in our case, where name
is equal to "Masha"
).