Skip to content

Instantly share code, notes, and snippets.

@RobertFischer
Last active February 27, 2019 18:31
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 RobertFischer/89761654c71dd365eb24cafb40d98791 to your computer and use it in GitHub Desktop.
Save RobertFischer/89761654c71dd365eb24cafb40d98791 to your computer and use it in GitHub Desktop.
Faking variant types within Java
enum Variant<T> {
Foo(1),
Bar(true);
private final T data;
private Variant(T data) {
this.data = data;
}
public T unwrap() {
return this.data;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment