-
-
Save rightfold/4a5fa409e0e8c1913249 to your computer and use it in GitHub Desktop.
This file contains 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
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