Variable Help

a = 5;
b = 2;
a = a + 1;
result = a - b;


I understand most of it but is "a = a + l" optional or does it serve a purpose. I couldn't find it anywhere online.
It depends. In this case, it's just making a = 6 before doing the result calculation.

It's optional, in a sense; leaving it out would make the result calculation 5 - 2.

It really all depends on context and what you're actually trying to do.
Last edited on
a=a+1; increases value of a by 1
1
2
a=5;
a=a+1; //now a==6 
Last edited on
Ahh; yeah I'm basically learning all this from the tutorial on the site. Taking notes on all this D:
It's manipulating the value at runtime. This capability is very important but often overlooked because it's pretty straight-forward.
Topic archived. No new replies allowed.