Created
March 24, 2016 07:29
-
-
Save abenedykt/5cf038a75a1af90c3445 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
public struct Maybe<T> where T : class | |
{ | |
public T Value { get; } | |
public bool HasValue => Value != null; | |
public bool HasNoValue => !HasValue; | |
private Maybe(T value) | |
{ | |
Value = value; | |
} | |
public static implicit operator Maybe<T>(T value) | |
{ | |
return new Maybe<T>(value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment