Created
March 14, 2019 22:32
-
-
Save mchmielarz/dc2f3efb0bdd7b73bd8cfeb18d8a9001 to your computer and use it in GitHub Desktop.
for-comprehension: Combining parts into a car using flatMap
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
final Option<Car> ourShinyCar = | |
body().flatMap( | |
b -> engine().flatMap( | |
e -> wheels().map( | |
w -> new Car(b, e, w) | |
) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment