This infix operator has the same operand on both sides.
It usually does not matter whether you pass the same operand twice to an infix operator. Comparison operators, however, are a special case and care must be taken when using them. If both operands of these operators are the same, the comparison will usually always evaluate to the same value (true
or false
). Since this result has the capacity to critically alter the flow of the program, it is suggested that you take another look at this expression to avoid accidentally creating a bad if
condition.
// This if condition is always false
if (value > value) {
// ...
}
if (value > MAX_PERMISSIVE_VALUE) {
// ...
}