Devoxx - filter, partition and offset

Richard Bair richard.bair at oracle.com
Wed Apr 3 08:56:14 PDT 2013


On Apr 3, 2013, at 8:29 AM, James Shaw <js102 at zepler.net> wrote:

> On 3 Apr 2013 16:10, "Brian Goetz" <brian.goetz at oracle.com> wrote:
>> 
>>>> Perhaps keep() and reject()? I'm sure there are other names, but
>>>> filter alone feels very unclear. (I can't remember which it is now).
>>> 
>>> Of the things in my email, its this single filter() method that most
>>> bothers me (and wasn't commented on).
>> 
>> A few people (but not many) have raised this issue before.  And, it's
>> been discussed by the EG.  The consensus was that this is maybe
>> something that maybe confuses some people for about the first 15
>> seconds, and thereafter they never think about it again.
> Fwiw, I'd expect filter to retain elements that satisfy a predicate. Any
> other method would feel like a double negative to me.

I think that's exactly why "filter" is a poor name choice. It seems to me that if a method called "filter" returns true, then the item should be filtered. And that is the opposite of what you're saying, isn't it? Hence, "filter" is not an intuitive name.

Richard



More information about the lambda-dev mailing list