Last active
July 16, 2017 22:42
-
-
Save cameronpresley/da0af475f61a73ec9cae392b97824f98 to your computer and use it in GitHub Desktop.
Extension method for Nullable to Option
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 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