Filter and Contains
paoloalby opened this issue · comments
Hi, here's my problem.
I have a "allPlayers" array Entity.
I have a "players" Relationship between a "team" and a "allPlayers" entities.
I want a list of all players that are not in this team yet.
So:
`func availablePlayer(_ team:Entity) -> [Entity] {
let playersTeam = players.filter { $0.subject == team }.flatMap { [$0.object] }
let playersAvailable = allPlayers.filter { !playersTeam.contains($0) }
return playersAvailable
}`
in playersTeam will be stored the allPlayers in players relationship given a team.
Then, I want to filter the allPlayers array that not contains the playersTeam.
but the !playersTeam.contains($0)
give me an error.
Entity has not "contains" method.
It only has "contains(where:)"
How can I achieve my result?
Hey,
I believe you are asking the question on StackOverflow here. Let me know if the answer works out. If not, please reopen the issue. Thank you!