From: "David A. Black" Date: 2008-04-12T02:26:33+09:00 Subject: Re: delete_if, select and (lack of) delete_if!, self.POLS == false Hi -- On Sat, 12 Apr 2008, Saku Ytti wrote: > On (2008-04-12 01:32 +0900), David A. Black wrote: > > Thanks everyone for fast reply. > >>> 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? >> >> You should use #reject, which is non-destructive. > > I guess I wasn't being clear, indeed reject removes the need for > non-mutating delete_if, which would make them equal. However, we're still > without method that does select, but mutates the returned elements out from > the original array. > If we'd have it, I guess select! would be bit odd name for it? And if it would > be delete_if! then mutating delete_if would be even more surprising? > > Also, I may be biased with my own problem thinking that select that removes > elements from array is typical need. Just feels so at the moment. So you want a kind of #keep_if ? 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!