Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
for-comprehension: Combining parts into a car using flatMap
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