Last active
November 13, 2016 04:03
-
-
Save artur-s/4e14f557e3d3018bc338f7b37d4e637b to your computer and use it in GitHub Desktop.
Operators for matching option and nullable
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
module Option = | |
let (|??) = defaultArg | |
let (|?) nullable d = if isNull nullable then d else nullable | |
// usage | |
open Option | |
[] |> List.tryHead |?? 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment