Consider this piece of code:
Func<int, bool> TestGreaterThanOne = delegate(int a) { if (a > 1) return (true); else return(false); };
In the above code, I cannot delete the else else return (false) statement. The compiler warns that not all code paths return a value. But in the following code that uses lambda ...
Func<int, bool> TestGreaterThanOne = a => a > 1;
I donβt need to have an βelseβ statement - there are no compiler warnings, and the logic works as expected.
What mechanism does play here so that I don't have an "else" expression in my lambda?
source share