Skip to content

Instantly share code, notes, and snippets.

@chris-martin
Last active December 23, 2015 08:09
Show Gist options
  • Save chris-martin/6605481 to your computer and use it in GitHub Desktop.
Save chris-martin/6605481 to your computer and use it in GitHub Desktop.
abstract class Maybe<A> {
Maybe() { }
abstract A toNullableReference();
}
final class Just<A> extends Maybe<A> {
private final A value;
Just(A value) {
this.value = value;
}
@Override
A toNullableReference() {
return value;
}
}
final class Nothing<A> extends Maybe<A> {
@Override
A toNullableReference() {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment