In Java 8 how can I filter a collection using the Stream
API by checking the distinctness of a property of each object?
For example I have a list of
Late to the party but I sometimes use this one-liner as an equivalent:
((Function) Value::getKey).andThen(new HashSet<>()::add)::apply
The expression is a Predicate
but since the map is inline, it works as a filter. This is of course less readable but sometimes it can be helpful to avoid the method.