Skip to content

Commit

Permalink
Removeにオーバーロード生やした
Browse files Browse the repository at this point in the history
  • Loading branch information
taiseiue committed Jan 1, 2025
1 parent 38511bd commit f716be2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Losetta.Runtime/Core/Extension/Alice.Core.Dictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ public static bool Remove(this Dictionary<Variable, Variable> dict, Variable key
{
return dict.Remove(key);
}
public static bool Remove(this Dictionary<Variable, Variable> dict, Variable key, [Ref] Variable value)
{
#if NETCOREAPP2_0_OR_GREATER
bool cond = dict.Remove(key, out var result);
#else
dict.TryGetValue(key, out var result);
bool cond = dict.Remove();
#endif
if (cond)
{
value.Assign(result);
}
else
{
value.AssignNull();
}
return dict.Remove(key);
}
public static void TrimExcess(this Dictionary<Variable, Variable> dict)
{
dict.TrimExcess();
Expand Down

0 comments on commit f716be2

Please sign in to comment.