添加字典扩展
This commit is contained in:
parent
fc916c10de
commit
1efc671213
|
@ -0,0 +1,12 @@
|
||||||
|
using Sanchime.Functional.Products;
|
||||||
|
|
||||||
|
namespace Sanchime.Functional.Extensions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字典扩展
|
||||||
|
/// </summary>
|
||||||
|
public static class DictionaryExtension
|
||||||
|
{
|
||||||
|
public static Option<T> Lookup<K, T>(this Dictionary<K, T> dictionary, K key) where K: notnull
|
||||||
|
=> dictionary.TryGetValue(key, out T? value) ? Option.Some(value) : Option.None;
|
||||||
|
}
|
Loading…
Reference in New Issue