Created
March 6, 2018 15:07
-
-
Save rnaufal/08c64a225d47150b371a66a72890269e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collection<Car> allPeopleCars = people | |
.stream() | |
.map(Person::getCars) | |
.flatMap(mayHaveCars -> mayHaveCars.map(Collection::stream).orElseGet(Stream::empty)) | |
.collect(Collectors.toList()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment