Re: Iterate through array and delete if match
- From: Ragav Satish <ragavsatish@xxxxxxxxx>
- Date: Fri, 3 Oct 2008 19:41:57 -0500
Tim Hunter wrote:
jackster the jackle wrote:
puts range
end
end
Is this the correct way to delete matched entries from an array?
Thanks
John
Use delete_if instead.
Or Array#reject!
deleting while iterating with each is undefined behavior. It's like
sawing off the tree branch you are sitting on.
--
Posted via http://www.ruby-forum.com/.
.
- Follow-Ups:
- Re: Iterate through array and delete if match
- From: jackster the jackle
- Re: Iterate through array and delete if match
- References:
- Iterate through array and delete if match
- From: jackster the jackle
- Re: Iterate through array and delete if match
- From: Tim Hunter
- Iterate through array and delete if match
- Prev by Date: Re: Iterate through array and delete if match
- Next by Date: Re: Iterate through array and delete if match
- Previous by thread: Re: Iterate through array and delete if match
- Next by thread: Re: Iterate through array and delete if match
- Index(es):
Relevant Pages
|