Cedric Bosch

Ranch Hand

Posts: 99

5

posted 1 year ago

I've found 2 question in enthuware where the answer

First this :

a, b and c take the value of 9. So it looks like when chaining "=" it goes from right to left.

Second question :

I'm not sure what I'm missing. Do they mean that the presence of the "!" operator make it so it's going left to right ?

**seem**a bit contradictory at first glance, so I'd like some clarification.First this :

a, b and c take the value of 9. So it looks like when chaining "=" it goes from right to left.

Second question :

__Explanation of the answer__:

Note that boolean operators have more precedence than =. (In fact, = has least precedence of all operators.)

so, in (b2 != b1 = !b2) first b2 != b1 is evaluated which returns a value 'false'. So the expression becomes false = !b2. And this is illegal because false is a value and not a variable!

Had it been something like (b2 = b1 != b2) then it is valid because it will boil down to : b2 = false.

Because all an if() needs is a boolean, now b1 != b2 returns false which is a boolean and as b2 = false is an expression and every expression has a return value (which is actually the Left Hand Side of the expression). Here, it returns false, which is again a boolean.

Note that return value of expression : i = 10 , where i is an int, is 10 (an int).

I'm not sure what I'm missing. Do they mean that the presence of the "!" operator make it so it's going left to right ?