Assume we have the following array of tuples…

let arthur = (facebook: "islandjoe", twitter: "islandjoe")
let joe = (facebook: "joeblow", twitter: "joeblow1")
let john = (facebook: "john.doe", twitter: "johndoe")

let users = [arthur, joe,  john]

and we just want to simply filter arthur out from the rest.

The fastest thing that comes to mind would be this:

for (facebook, twitter) in users {
  if facebook == "islandjoe" && 
     twitter == "islandjoe" {
    print("Arthur is on facebook and twitter")
    break
  }
}

//-> Arthur is on facebook and twitter

But it would be much better if the filtering happens on the loop declaration itself, and not inside the loop body:

for (fb, twitter) in users where 
    fb == "islandjoe" && 
    twitter == "islandjoe" {
  print("Arthur is on facebook and twitter")
}
   
   //-> Arthur is on facebook and twitter

Now this is much cleaner as there's no if conditional statement occupying the entire loop body, plus, you don't need to break out of the conditional. The intent is communicated much clearly from the outset already.

But this being Swift, a succinct version is provided, and does it look beautiful!

for case ("islandjoe", "islandjoe") in users {
  print("Arthur is on facebook and twitter")
}

The for-case loop does away with the repeating constants and the logical AND operator that plagues if based filtering.

So, we can use for-case loops when filtering items from arrays.