Why are out parameters inside an if statement condition not local to the if block? [Answered]
Is this because of how it ends up compiling val above the if statement?
if (dictionary.TryGetValue(key, out var val))
{
}
// why can I access val here?val there because the if (!TryGetValue) return; pattern is super common in .NET, and we wanted that pattern to work with out variable declarationsvalif (!TryGetValue) return;int i;
if (!TryGetValue(out i)) return;
// Do something with i