From: Robert Dober Date: 2008-04-12T02:08:39+09:00 Subject: Re: delete_if, select and (lack of) delete_if!, self.POLS == false On Fri, Apr 11, 2008 at 6:46 PM, 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. No, I agree with you but OTOH not many seem to see the need for this and the community is rather pragmatic about these things. I would prefer to have a reject and a reject! but I am pragmatic about democracy ;), and a large majority seems not to see the need for this. Now I would love to stand corrected of course ;). Cheers Robert > > -- > ++ytti > > -- http://ruby-smalltalk.blogspot.com/ --- Whereof one cannot speak, thereof one must be silent. Ludwig Wittgenstein