Skip to content

Instantly share code, notes, and snippets.

@sumew
Created September 23, 2016 14:51
Show Gist options
  • Save sumew/66c1ada0a1eb50b201c3a12503d56850 to your computer and use it in GitHub Desktop.
Save sumew/66c1ada0a1eb50b201c3a12503d56850 to your computer and use it in GitHub Desktop.
Number plusOne = Match(obj).of(
Case(instanceOf(Integer.class), i -> i + 1),
Case(instanceOf(Double.class), d -> d + 1),
Case($(), o -> { throw new NumberFormatException(); })
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment