Devoxx - filter, partition and offset
forax at univ-mlv.fr
Wed Apr 3 06:58:56 PDT 2013
On 04/03/2013 03:40 PM, Stephen Colebourne wrote:
> On 3 April 2013 12:36, Stephen Colebourne <scolebourne at joda.org> wrote:
>> It didn't come up in the Devoxx lab, but I found the filter() method
>> confusing when reading code in the talks. It was not obvious to me
>> whether it was filtering in or out.
>> I was then surprised that there was only one method in the API for
>> filtering, rather than two - one to remove and one to retain. While
>> clearly they are a logical not, in code readbility terms its typically
>> a lot clearer.
>> 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).
> The method is learned knowledge:
> stream.filter(a > 6)...
> There is no way from just reading this to *know* whether it is keeping
> or rejecting a > 6. I have to rack my brain and remember which way
> around it is.
> Yes its one extra method or longer. But its much more readable:
> stream.filterKeeping(a > 6)...
Filter is a common idiom in a lot of languages,
while I agree with you that the name can be better,
I (and the EG) think the concept is enough important to *not* choose a
More information about the lambda-dev