Created
April 22, 2026 23:15
-
-
Save talesin/c66302ea9fb145bfb13145542eee65a8 to your computer and use it in GitHub Desktop.
Generci tryParse for 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
| /// TryParse utility for various types | |
| let inline tryParse< ^a when ^a : (static member TryParse : string * byref< ^a> -> bool)> s : ^a option = | |
| let mutable value = Unchecked.defaultof< ^a> | |
| if (^a : (static member TryParse : string * byref< ^a> -> bool) (s, &value)) then Some value | |
| else None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment