title: Comparing two arrays in swift, with different lengths
body: <p>I want to compare two arrays with each other and append the value that is not in the other array to a new array. The problem now is that all of the values that does not equal the other array already get appended, but I want only the values that are new in the other array getting appended.</p>
  
  <p>I hope that the problem is clear. Sorry if it's a very vague question. I try to be clear haha.
  The code and output is printed below:</p>
  
  <pre><code>// Iterate through all possible values
  for i in 0...messages.count-1{
      var match = false
  
      for r in 0...self.messages.count-1{
         println("NIEUWE" + messages[i].getID() + "OUDE" + self.messages[r].getID())
  
  
          if(messages[i].getID().toInt() == self.messages[r].getID().toInt()){
  
              var match = true
  
              println(match)
              break
          }
  
  
      }
  
      if (!match) {
          newArray.append(messages[i])
          println(newArray)
      }
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>NIEUWE170OUDE170
  NIEUWE170OUDE171
  true
  [PostDuif.Message]
  NIEUWE171OUDE170
  true
  [PostDuif.Message, PostDuif.Message]
  NIEUWE172OUDE170
  true
  </code></pre>