Design for collections upgrades

Brian Goetz brian.goetz at
Tue Mar 8 13:24:22 PST 2011

>> Further, I think the choice of eager/lazy is a reasonable one to give
>> the programmer.  Programmers who do not need the features offered by
>> laziness shouldn't need to learn how laziness works just to use the new
>> collection operations.
> I don't see the need of having a eager filter().

Java programs have lots of code that basically looks like this:

ArrayList<T> filtered = new ArrayList<T>();
for (T t : otherList)
     if (predicate(t))

This can be replaced by the one liner:

ArrayList<T> filtered = otherList.filter(predicate);

Not only is it shorter, it is clearer, less error-prone, and does not 
force the programmer to use side effects to do the computation.

More information about the lambda-dev mailing list