3 ms·
Surely tuples should get rid of the need for that hack?
by JosephRedfern 10y ago
Surely tuples should get rid of the need for that hack?
- simcop2387 10y agoThat's what I'd hope, but I've seen in other languages where instead it ends up error_type function(out data, out data2, ...); instead. Given that C# has proper try/catch and other mechanisms of error handling I'd hope that this pattern won't repeat itself.
- flukus 10y agoI hope so, but I expect there existence to filter out a lot more slowly.
- hermitdev 10y agoSure for new code, but I think the concession here is that it provides convenience for dealing with existing code/libraries. Additionally, it allows restricting the scope of the variable, like in the TryParse examples. The output variable in something like "if (int.TryParse(someString, out var i))" is now scoped to the if block. It cannot be used in the else, nor inadvertently later in the parent scope.