by ericsink · 3y ago · 0 comments
But even more often, I find myself wishing C# blocks were expressions.
In F#, I could do this:
let x =
let z = whatever
...
value
and z is inside a local scope.So in C#, I want to do:
var x =
{
var z = whatever;
...
value
};
Maybe it's just me. var x = (() =>
{
var z = whatever;
...
return value;
})();
It is not the most performant way to write that code and if the contents start to get long, refactoring to its own method starts to feel more likely, but in one-off cases, it seems fine for how ugly it is.