From: "David A. Black" Date: 2008-10-04T12:00:54+09:00 Subject: Re: Iterate through array and delete if match Hi -- On Sat, 4 Oct 2008, jackster the jackle wrote: >> Or Array#reject! >> >> deleting while iterating with each is undefined behavior. It's like >> sawing off the tree branch you are sitting on. > > > hehehe...I know what you mean! > > Tim's solution worked, I used: > > @acl_all_array.each do |range| > if range[/access-list/] > @acl_range.push(range) > end > end > @acl_all_array.delete_if { |x| x[/access-list/] } > > Thanks for all the help guys...I am going to read up on Array#reject! to > see how that might help me. Check out Array#partition too. What you've got there looks like it could be: @acl_all_array, @acl_range = @acl_all_array.partition do |range| range[/access-list/] end or something like that. David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL * * Co-taught with Patrick Ewing! See http://www.rubypal.com for details and updates!