March 2019
Intermediate to advanced
242 pages
6h 21m
English
The following is an example to demonstrate how you can use an _ (underscore) to mark unused lambda parameters. The following code uses the BiFunction<T, U, R> functional interface which can accept two arguments (T and U), and returns a value of the type R:
BiFunction<Integer, String, Boolean> calc = (age, _) -> age > 10;
In the preceding example, since the lambda expression assigned to the BiFunction functional interface uses just one of the method parameters (that is, age), JEP 302 proposes using the underscore to mark the unused parameter.
The following code highlights a few use cases to illustrate how you would use the same code without the convenience of marking unused lambda parameters (the comments state ...
Read now
Unlock full access