Namespace: FsToolkit.ErrorHandling
FsToolkit.ErrorHandling
tryGetValue tries to get the value associated with a key from a dictionary. Returns Some value if the key exists, or None if it does not.
tryGetValue
Some value
None
Note: This function is not available when using Fable (JavaScript/Python compilation).
'key -> ^Dictionary -> ^value option
where ^Dictionary has a member TryGetValue: 'key * byref<^value> -> bool.
^Dictionary
TryGetValue: 'key * byref<^value> -> bool
open System.Collections.Generic let dict = Dictionary<string, int>() dict["apples"] <- 5 dict["bananas"] <- 3 let result : int option = dict |> Option.tryGetValue "apples" // Some 5
Last updated 4 months ago
open System.Collections.Generic let dict = Dictionary<string, int>() dict["apples"] <- 5 let result : int option = dict |> Option.tryGetValue "bananas" // None