Skip to content

Instantly share code, notes, and snippets.

@cajar1988
Last active November 1, 2015 22:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cajar1988/1b80c676e884c642ffbe to your computer and use it in GitHub Desktop.
final int price = Match.of(vehicle)
.whenIs(Vehicle.CAR).then(() -> 17000)
.whenIs(Vehicle.BIKE).then(() -> 2000)
.whenIs(Vehicle.SKATEBOARD).then(() -> 500)
.getOption().orElseThrow(() -> new IllegalStateException("Unsupported vehicle=" + vehicle));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment