Skip to content

Instantly share code, notes, and snippets.

@RodrigoPinho
Created October 23, 2021 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RodrigoPinho/dbafd1c0463fa1ffd202e25b2feea888 to your computer and use it in GitHub Desktop.
Save RodrigoPinho/dbafd1c0463fa1ffd202e25b2feea888 to your computer and use it in GitHub Desktop.
public static String getPatternMatchingMessage(Object object) {
return switch (object) {
case String s -> "Type: String, value: " + s;
case Integer i -> "Type: Integer, value: " + i;
case null -> "Null object";
default -> "Type: Unknown, value: " + object.toString();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment