Skip to content

Instantly share code, notes, and snippets.

@mchmielarz
Created March 14, 2019 22:35
Show Gist options
  • Save mchmielarz/619b9c540a198344dea947fc35e3a0a1 to your computer and use it in GitHub Desktop.
Save mchmielarz/619b9c540a198344dea947fc35e3a0a1 to your computer and use it in GitHub Desktop.
for-comprehension: Building a car with Java's for-comprehension
final Option<Car> car = For(
 engine(),
 wheels(),
 body()
).yield(
 (engine, wheels, body) -> new Car(body, engine, wheels)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment