From: Shawn Anderson Date: 2008-10-04T09:37:12+09:00 Subject: Re: Iterate through array and delete if match ------=_Part_27119_17870940.1223080720981 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I believe there is a method on Array called delete_if for just such a case.. IIRC /Shawn On Fri, Oct 3, 2008 at 5:18 PM, Tim Hunter wrote: > 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/ > > ------=_Part_27119_17870940.1223080720981--