I’m trying to find a more concise expression for the “keyMapper” function parameter in the following call Collectors.toMap()
:
List roster = ...;
Map map =
roster
.stream()
.collect(
Collectors.toMap(
new Function() {
public String apply(Person p) { return p.getLast(); }
},
Function.identity()));
It looks like I should be able to embed it using a lambda expression, but I can’t find one that compiles it. (I’m pretty new to Lambdas, so that’s no surprise.)
Thank you.
-> Update:
As stated in the accepted answer
Person::getLast
it is what I was looking for and it is something I had tried. However, the problem was the BETA_8 night build of Eclipse 4.3, which was flagged as bad. When compiled from the command line (which I should have done before publishing), it worked. So, it’s time to file a bug with Eclipse.org.
Thank you.