Created
July 27, 2021 19:43
-
-
Save grzesiek-galezowski/419892d5cd6e4c838ebe6240f5c91529 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class C1 | |
{ | |
[Test] | |
public void METHOD() | |
{ | |
var lookupValue1 = Lookup(new Dictionary<string, string?>(), "a"); | |
var lookupValue2 = Lookup(new Dictionary<string, string>(), "a"); | |
} | |
public LookupValue<TV> Lookup<TK, TV>(Dictionary<TK, TV?> d, TK key) | |
where TK : notnull | |
where TV : notnull | |
{ | |
if (d.TryGetValue(key, out var result)) | |
{ | |
return new LookupValue<TV>(result); | |
} | |
else | |
{ | |
return new LookupValue<TV>(default); | |
} | |
} | |
public record LookupValue<T>(T? Value) where T : notnull; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment