Enhanced C#
Language of your choice: library documentation
|
Enables access to TryGet extension methods for retrieving items from a collection without risk of exceptions. More...
Enables access to TryGet extension methods for retrieving items from a collection without risk of exceptions.
Public Member Functions | |
V | TryGet (K key, out bool fail) |
Gets the item for the specified key or index, and does not throw an exception on failure. More... | |
V Loyc.Collections.ITryGet< in in K, out out V >.TryGet | ( | K | key, |
out bool | fail | ||
) |
Gets the item for the specified key or index, and does not throw an exception on failure.
key | A lookup key that might be associated with a value in this object. If K is an integer, this value could be an index into a list. |
fail | TryGet sets this to true on failure or false on success. |
This method should never intentionally throw (e.g. don't throw if key == null) although it may use third-party methods that throw (e.g. Object.Equals()).
Ideally the return type would be Maybe<T> but that design would not allow variance on the output type (out V). Instead, an extension method TryGetExt.TryGet<K, V>(ITryGet<K, V>, K) is provided that returns Maybe<V>.