RFR: 8023339 : (xs) Rename Collection.removeIf(Predicate) to removeAll(Predicate)
guy.steele at oracle.com
Thu Sep 5 17:31:57 UTC 2013
Let me point out that the "xxxIf" form of name for this idea (removing elements
of a list that satisfy a predicate, or otherwise operating on the elements of a list
that satisfy a predicate) has a history tracing back to the year 1979. That's more
than a third of a century.
On Sep 5, 2013, at 9:18 AM, Matthew Adams <matthew at matthewadams.me> wrote:
> I know it's probably too late, but it occurred to me that
> "removeWhere(Predicate)" seems appropriate:
> coll.removeWhere(s -> s.size() > 3);
> On Thu, Sep 5, 2013 at 4:25 AM, Alan Bateman <Alan.Bateman at oracle.com>wrote:
>> On 04/09/2013 22:08, Mike Duigou wrote:
>>> Hello all;
>>> The naming of the Collection.removeIf(Predicate) method has always been
>> an uncertain choice. We've gone back and forth between naming it removeIf
>> and overloading the existing removeAll(Collection) with a
>> removeAll(Predicate). Now that all other library and language decisions
>> seem to be settled it seems reasonable to make a final decision on this
>> method naming.
>>> This patch proposes to use the removeAll(Predicate) overload. This
>> choice is made to increase the discoverability of the method and to "reuse"
>> the existing user understanding of the removeAll name. There is a minor
>> source incompatibility induced by overloading the removeAll name--if
>> explicit null is passed then a compiler cannot resolve which overload to
>> use. Since null is not a legal value for either overload this source
>> incompatibility is expected to only affect tests which check to see what
>> response implementations return for null. The ambiguity can be resolved by
>> providing a cast to either the Collection or Predicate types to select the
>> appropriate overload.
>> This looks okay to me too.
> mailto:matthew at matthewadams.me <matthew at matthewadams.me>
> googletalk:matthew at matthewadams.me
More information about the core-libs-dev