From: Tony Arcieri Date: 2010-02-12T07:59:38+09:00 Subject: Re: Delete Item In Array If Conditions Met --000e0cd7080ee9fbf4047f5b1ac7 Content-Type: text/plain; charset=ISO-8859-1 In addition to reject! there's also Array#delete_if On Thu, Feb 11, 2010 at 3:55 PM, Siep Korteling wrote: > Chris Kalaboukis wrote: > > Hi all: Ruby newbie here. Been trying to get this code to work but am > > having a tough time of it. Can anyone else please help me out? > > > > I've read from a db into an array, and would like to go through the > > array and remove elements which match a specific criteria. Here is the > > code that I'm using: > > > > > > # load array > > @array = Capture.find(:all) > > > > # iterate through array > > > > for x in @array > > x.reject!{|x| x.text =~ "something"} > > end > > reject! does the iterating for you, so you can (must) leave out the for > loop. > > hth, > > Siep > > > -- > Posted via http://www.ruby-forum.com/. > > -- Tony Arcieri Medioh! A Kudelski Brand --000e0cd7080ee9fbf4047f5b1ac7--