+ 5
what's mean x -= y += 9
You can use multiple assignment operators in one line, such as x -= y += 9. Whether it is equal to x=x-9 &y=y+9 & x-9=y+9 ???
8 odpowiedzi
+ 9
x = x-(y+9)
is what i would say
+ 6
This doesn't exactly answer the question but I have to say it:
You can write it this way but it's bad practice.
Also bad practice is nested ternaries.
Generally when we write code we want to write it in a way that is easily understood.
e.g.
If you look at a well written piece of code 1 year later you can understand what's happening in the code fairly quickly and make the necessary adjustments/corrections/changes.
If you look at a piece of code that's written like a cipher 1 year later I guarantee you that you'll say:
"famp;@ this, ill rewrite the whole thing."
+ 4
Gordie in the last part, x will be assigned to x-y-9 and not x-y+9.
But you cleared that in last 2 lines so it doesn't matter 😄
+ 1
x-=y+=9 means
x-=(y+=9)
I.e
y=y+9
x=x-y
+ 1
It means
y=y+9
x=x-y
0
Breakdown the string by 'equal' sign. You get x=x-y as there is x-=y;
and y=y+9 as there is y+=9
So, substitute and get the final result as follows,
x=x-(y+9).
0
x = x - y, where y = y + 9