Unclear multiple conditions in a while statement

Viewed 32

I have 3 variables, need to roll in the loop while x < y and y < z and increment y.

I saw this piece of code and I don't understand what the statement inside the brackets evauluates to:

while (x < y < z){
    y++;
}

Of course the right way to do it is:

while (x < y && y < z){
    y++;
}

For int x = 1, y = 2, z = 3 the first loop is infinite, and the second run one time, as expected.

My question is about the first condition statement - what actually happening?

0 Answers
Related