From: Rodrigo Rosenfeld Rosas Date: 2011-06-18T00:07:51+09:00 Subject: [ruby-core:37200] Re: Surprised by Array#delete_if in Ruby 1.9.2 I agree the name is confusing, specially because it doesn't seem to give any hints on return values. Maybe it should be aliased as Array#without if the return value is expected, but indeed it wouldn't state in the name that the array itself would be modified. Maybe Array#without! should be used instead but I still think it is confusing... I don't think that returning the deleted items would be any better for the method name though... I can't give any suggestions for these method names right now, but I do agree with you that these names are very confusing. Best regards, Rodrigo. Em 17-06-2011 12:00, Mike Leddy escreveu: > Hello, > > Being familiar with the use of Array#delete and Array#delete_at which return > the item deleted I was somewhat surprised by the behaviour of Array#delete_if > returning the resultant array and NOT an array of the items that were deleted. > > I would like to argue that it should return the items that are deleted: > > + Maintain similarity with Array#delete, and Array#delete_at "principle of > least surprise" > + To really be the complement of Array#keep_if which "correctly" returns > the array that is 'kept'. > + Writing code that achieves the same effect is a little difficult to read > and requires another variable (using parallel assignment + > Enumerator#partition) eg: > > b, a = a.partition {|x| x%2==0} > > Anyone else agree ? > > Thanks, > > Mike > > > > >