From: Tim Hunter Date: 2008-10-04T09:18:24+09:00 Subject: Re: Iterate through array and delete if match jackster the jackle wrote: > I'm trying to delete elements of an array if they match a string but my > code always leaves some matches and I think it's because it's having > trouble iterating through the same array it is trying to delete from, is > that true? > > Here is the code: > > @acl_all_array.each do |range| > if range[/access-list/] > @acl_all_array.delete(range) > puts range > end > end > > Is this the correct way to delete matched entries from an array? > > Thanks > > John Use delete_if instead. -- RMagick: http://rmagick.rubyforge.org/