Skip to content

Instantly share code, notes, and snippets.

@rightfold

rightfold/.cs Secret

Created September 1, 2015 08:06
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 rightfold/4a5fa409e0e8c1913249 to your computer and use it in GitHub Desktop.
Save rightfold/4a5fa409e0e8c1913249 to your computer and use it in GitHub Desktop.
struct Optional<T> {
private bool present;
private T value;
public Optional(T value) {
present = true;
this.value = value;
}
public void Clear() {
present = false;
this.value = default(T);
}
public void Set(T value) {
present = true;
this.value = value;
}
public T Get() {
if (present) {
return value;
} else {
throw new Exception("fuck");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment