Forum Moderators: phranque
class Quirky {
public static void main(String[] args) {
int x = 1;
int y = 3;
System.out.println(x == (x = y)); // false
x = 1; // reset
System.out.println((x = y) == x); // true
}
} int oldX = x;
x = y;
return oldX == y; [edited by: not2easy at 6:02 pm (utc) on Feb 20, 2023]
[edit reason] Please see TOS [webmasterworld.com] [/edit]
x == (x = y)
left = x ;
right = ( x = y ) ; ( after this line, "right = y" and "x=y" )
left == right ; (return false since left = x and right = y )
(x = y) == x
left = ( x = y ) ; ( left = y and x = y )
right = y ;
left == right ( return true, both sides are equal to "y" )