I am using TryGetValue on a Dictionary in F# and it returns an object bool * Dictionary<int, object>
I have been googling for hours but how do I access the bool component of this object so I can check if it has returned a value?
Please save me from going postal...
Facebook Touch is an advanced Facebook app that has many distinct features. H5 apps developed it as an app made especially for touchscreen phones. Available and applicable across all smartphones, Facebook Touch offers a fine user interface and serves as an alternative to the typical Facebook App.
There are a few options.
The simplest is probably:
let found, value = dict.TryGetValue key
Alternatively:
let pair = dict.TryGetValue key
let found = fst pair
let value = snd pair
The most common pattern is this:
match dict.TryGetValue key with
| true, value -> (* do something with value *)
| _ -> (* handle the case of value not found *)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With