3 ms·
That is ugly. What he's doing is creating an anonymous function which takes no parameters and returns an int. That's what a Func<int> is, and then he is execut
by LandR 8y ago
That is ugly.
What he's doing is creating an anonymous function which takes no parameters and returns an int. That's what a Func<int> is, and then he is executing that function, that's the () bit after }))
He could write it nicer as:
"+" => Add(),
Where he defines add as
int Add() => a + b;
He's just doing too much inline, 99% of C# developers would not write code as he has done there.
Its' the bloggers code style that is the problem here, not the new switch syntax. Although he probably did it to make the example more self contained and terse.
- rattray 8y agoI agree with your conclusion, but let's keep the conversation civil.
- Dylan16807 8y ago> He's just doing too much inline It's two short lines. The problem is that he's writing a small but more than one line bit of code, so the overhead of the anonymous function is just as big as the code itself, and arguably more complex.