Skip to content

Instantly share code, notes, and snippets.

@abenedykt
Created March 24, 2016 07:29
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 abenedykt/5cf038a75a1af90c3445 to your computer and use it in GitHub Desktop.
Save abenedykt/5cf038a75a1af90c3445 to your computer and use it in GitHub Desktop.
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