When checking if a integer is the same or above a current number.. so I type
if (5 => 6) { //Bla }
but it shows this as a error. Why? Isn't it exactly the same as
if (5 >= 6) { //Bla }
The reason why it does not work is because =>
is not equivalent to >=
.
=>
is used in a lambda expression. Like :
(int x, string s) => s.Length > x
I do agree it is annoying. Before lambda expressions I used to get it wrong sometimes. Now I always know that one (=>
) is a lambda expression and and other (>=
) is the greater than equal to sign
Because the operator is >=
not =>
.
The writers of the language could have chosen either syntax, but had to choose one. Having two operators meaning the same thing would be confusing at best.
However, the operator is read "greater than or equal to" so it does make sense that the >
symbol is first.
Also =>
is now used for Lambda expressions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With