Skip to content

Instantly share code, notes, and snippets.

@jbrestan
Last active August 29, 2015 14:08
Show Gist options
  • Save jbrestan/80cc26a10852339974a1 to your computer and use it in GitHub Desktop.
Save jbrestan/80cc26a10852339974a1 to your computer and use it in GitHub Desktop.
Generic F# wrapper over BCL "static bool TryParse(string, out T)" pattern
let inline tryParse input =
let mutable result = Unchecked.defaultof< ^a>
if (^a: (static member TryParse : string -> ^a byref -> bool) (input, &result))
then Some(result) else None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment