Created
March 15, 2010 21:27
-
-
Save mulambda/333349 to your computer and use it in GitHub Desktop.
Active pattern for working with Nullable in F#
This file contains hidden or 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
let (|HasValue|Null|) (x:System.Nullable<_>) = | |
if x.HasValue then | |
HasValue (x.Value) | |
else | |
Null | |
let f x = | |
match x with | |
| HasValue v -> v + 1 | |
| Null -> 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment