Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if swift array does not contain object

I'm trying to filter a list of users from a Firebase query so that I only get users that are NOT listed in one of two arrays. The code I'm using doesn't work:

   let users = snapshot.childSnapshots.map {
                User(snapshot: $0)
            }.filter{
                guardiansArray.contains($0.key) == false || dependentsArray.contains($0.key) == false
        }

If I remove the ==false code, I get the opposite effect of what I want: I get a list of users that ARE in either of the two arrays. How can I get the reverse effect?

Thanks!

like image 608
winston Avatar asked Jul 02 '26 15:07

winston


1 Answers

It looks like you want to use && instead of ||.

like image 142
Vlad Avatar answered Jul 05 '26 05:07

Vlad