C# lambda operator
Last updated on June 7, 2013, 23:54 by Sebastian Mihai
I feel that Microsoft .NET creators could have come up with a better operator for lambda expressions than =>. The reason for this is that under certain circumstances, lambda expressions can be made to look goofily. Here's an example:
Func<long, bool> lambda = x => x <= 3;
I think that my problem with this syntax is that the = sign is already overloaded quite a bit. We use it for assignment, as well as ordinal and equality comparisons, such as <= and >=.
-> would be a great one, but, unfortunately, is taken.
I think a better operator could have been -->, improving, in my opinion, the appearance above statement:
Func<long, bool> lambda = x --> x <= 3;
If you use the materials on this page, or any other page on this web site, you do so at your own risk. They are provided "as is". No warranty is provided or implied. I neither guarantee that the materials will work, nor that they will not be harmful in any way.