I ran across this example and realized i don't fully understand what's going on here
if (a <- b) {
return false;
}
What is <-
in Java?
To support lambdas, Java has introduced a new operator “->”, also known as lambda operator or arrow operator. This arrow operator is required because we need to syntactically separate the parameter from the body. LambdaBody can be an expression or a block.
Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. (A >= B) is not true. <= (less than or equal to) Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.
&& is AND where as || is OR operator. && looks for false, means if first argument false, it wont test second whether it is true or false. || looks for true, means even though first argument false, it test for second. If both are false then false otherwise true. In && case both are true then true otherwise false.
See it in this way:
if (a < -b) {
return false;
}
There is no <-
operator in java.
Related, I've just found this question: What is the "-->" operator in C++?
There is no such operator in java. This means
if (a < -b) {
}
which is same as
if (a < - b) {
}
The -
sign need not be just by b
.
For int
types one could do
if (a <-- b) {
}
which will be same as
if (a < --b) {
}
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