ofPair
Namespace: FsToolkit.ErrorHandling
Transforms a bool * 'T value to 'T Option.
Function Signature
bool * 'T -> 'T OptionExamples
Example 1
let opt = Option.ofPair (true, 1)
// Some 1Example 2
let opt = Option.ofPair (false, 1)
// NoneExample 3
Instead of using this code snippet,
match Int32.TryParse "12" with
| true, x -> x
| false, _ -> 0
// 12you could use Option.ofPair if it better suits your use case
Last updated