Last active
February 27, 2019 18:31
-
-
Save RobertFischer/89761654c71dd365eb24cafb40d98791 to your computer and use it in GitHub Desktop.
Faking variant types within Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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