+ 1

somebody explain me the comand x++ in the app is says it is x=x+1 but this operation is impossible

x++ == x=x+1 <= this is impossible

18th Mar 2017, 3:42 PM
sargentov
sargentov - avatar
4 Respostas
+ 13
Why should that be impossible? It is correct. On the right side of the assignment, x is replaced by it's current value, then the calculation is excuted and then the result is assigned to x. Everything fine.
18th Mar 2017, 3:59 PM
Tashi N
Tashi N - avatar
+ 3
x++ is a short way of writing add 1 to x, the alternative is x = x + 1. Don't think of this as an algebraic formula it is simply saying I want to add one to the current value of x and store the result in the same variable.
18th Mar 2017, 4:21 PM
Shane
+ 1
in coding, this is impossible x == x + 1 that is what you're thinking, an equivalent, that equates to false x = x + 1 is an ASSIGNMENT, difference being if x = 4, now x = 5
18th Mar 2017, 5:17 PM
William La Flamme
William La Flamme - avatar
+ 1
thx
18th Mar 2017, 5:23 PM
sargentov
sargentov - avatar