Hi -- On Sat, 12 Apr 2008, ara.t.howard wrote: > > On Apr 11, 2008, at 10:26 AM, Saku Ytti wrote: >> Hey everyone, >> >> I was looking today for version of Array#select that would mutate the array >> by deleting selected elements from it. >> I first looked at delete_if, then noticed that it actually mutates original >> array and returns mutated array. I wonder would it make sense for delete_if >> not to mutate and return new array and delete_if! to mutate and return >> deleted >> elements? >> >> Of course what I want is simple method to implement, it just seems pretty >> typical desire for Array#select usage cases and also perhaps mutating >> delete_if is as well bit unexpected? Problem is, suggested change would >> break many current delete_if usage cases. > > a non-mutating delete_if is already there: > > array.select{|element| not orginal_condition(element)} > > ie > > odds = [0,1,2,3].select{|i| not i.even?} Also: odds = [0,1,2,3].reject {|i| i.even? } David -- Rails training from David A. Black and Ruby Power and Light: ADVANCING WITH RAILS April 14-17 New York City INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin See http://www.rubypal.com for details and updates!