Skip to content

Instantly share code, notes, and snippets.

@cameronpresley
Last active July 16, 2017 22:42
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 cameronpresley/da0af475f61a73ec9cae392b97824f98 to your computer and use it in GitHub Desktop.
Save cameronpresley/da0af475f61a73ec9cae392b97824f98 to your computer and use it in GitHub Desktop.
Extension method for Nullable to Option
public static class NullableExtensions
{
public static Option<T> ToOption<T>(this T? nullable) where T : struct
{
if (nullable == null) return Option<T>.None();
return Option<T>.Some(nullable.Value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment