Lambda leftovers

There are currently two items labeled as leftovers from the lambda work in Java 8. The first is the use of the underscore for unused parameters in lambda declarations. For example, in this very contrived example, all we care about are the Map values:

    Map<String, Integer> numbers = new HashMap<>(); 
    numbers.forEach((k, v) -> System.out.println(v*2)); 

That results in things like this in the IDE:

Once the use of the underscore is allowed, this code will look like this:

    numbers.forEach((_, v) -> System.out.println(v*2)); 

This allows better static checking of unused variables, allowing tools (and developers) to more easily identify ...

Get Java 9: Building Robust Modular Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.