title: Deleting items from an array requires multiple passes to remove them all
body: <p>I have an array of ~1200 ruby objects and I want to loop over them and delete the ones with names that contain words or parts of words.</p>
  
  <p>So I tried this:</p>
  
  <pre><code>list.each do |item|
    if item.name =~ /cat|dog|rat/i
      puts item.name
      list.delete(item)
    end
  end
  </code></pre>
  
  <p>It works, except that it seems to miss some items with names that should match. If I run it again it finds a few more, and if I run it another time it finds a few more. It finds less each time, but I have to run it 3 times in order to delete everything. </p>
  
  <p>Why in the world is this happening?</p>