From: Robert Dober Date: 2008-04-12T02:05:21+09:00 Subject: Re: delete_if, select and (lack of) delete_if!, self.POLS == false On Fri, Apr 11, 2008 at 6:36 PM, David A. Black wrote: > 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? } I guess even I could come up with an odd solution. (t'is 1 funny maybe?) R. -- http://ruby-smalltalk.blogspot.com/ --- Whereof one cannot speak, thereof one must be silent. Ludwig Wittgenstein