|
Enhanced C#
Loyc library documentation
|
Enables access to TryGet extension methods for retrieving items from a collection without risk of exceptions. Unlike IReadOnlyDictionary{K, V}, this interface supports variance (e.g. ITryGet{object, string} can be assigned to ITryGet{string, object}) and it does not throw when the key is null. More...
Enables access to TryGet extension methods for retrieving items from a collection without risk of exceptions. Unlike IReadOnlyDictionary{K, V}, this interface supports variance (e.g. ITryGet{object, string} can be assigned to ITryGet{string, object}) and it does not throw when the key is null.
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 K, 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 must not 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}.
Referenced by Loyc.Syntax.Les.Les2LanguageService.Parse(), and Loyc.Syntax.Les.Les3LanguageService.Parse().
1.8.7