3 ms·
Regarding "_": http://openjdk.java.net/jeps/302 http://openjdk.java.net/jeps/302 Example: BiFunction<Integer, String, String> biss = (i, _) -> String.valu
by krzyk 8y ago
Regarding "_": http://openjdk.java.net/jeps/302 http://openjdk.java.net/jeps/302
Example:
BiFunction<Integer, String, String> biss = (i, _) -> String.valueOf(i);
It basically means that one of the lambda parameters is unused.
And citing this JEP 302:
We are now free to complete the planned rehabilitation of underscore
to indicate an unused lambda, method, or catch formal parameter.
- virtualwhys 8y agoScala overloads underscore in various ways, my favorite being: val emails = users.map(_.email) Unlikely that will make its way into Java anytime soon, if ever, but it would be a nice enhancement -- being forced to pepper your code with lambda expressions a la `x => x.foo` is annoying when the alternative `_.foo` conveys the same meaning.