
-----------------------------------
Mr.Programmer
Wed Feb 27, 2008 7:15 pm

Kind of Stupid Question (+=,-=)
-----------------------------------
My question is, what do these two things mean: ' += ' and ' -="? 

I know that := means 'becomes', but these two i cant figure out. Here's an example:

vely -= GRAVITY 
    posx += round (velx) 
    posy += round (vely) 

Thanks!

-----------------------------------
Tony
Wed Feb 27, 2008 7:24 pm

RE:Kind of Stupid Question (+=,-=)
-----------------------------------
var += 42
is the short way of saying
var := var + 42

-----------------------------------
Mr.Programmer
Wed Feb 27, 2008 7:26 pm

Re: Kind of Stupid Question (+=,-=)
-----------------------------------
Ohhh. Then i guess var -= 22 is like saying ' var :+ var - 22 '?

If so then it makes sense. 

And thank you very much.

-----------------------------------
Bored
Thu Feb 28, 2008 7:26 pm

Re: Kind of Stupid Question (+=,-=)
-----------------------------------
There's also other including *=, /=, div=, and I beleive there might be more that I'm missing.

-----------------------------------
BigBear
Thu Feb 28, 2008 7:34 pm

Re: Kind of Stupid Question (+=,-=)
-----------------------------------
when you use := it means becomes or is therefore equal to and when you use += it means becomes itself plus whatever is next
So 
var word : string := "" %declares it as nothing
word := word +"hello" %is the same as
word+=word

-= means becomes itself - something

var num : int
put "Enter a number: "..
get num
num -= 2
put "Your number minus 2 is equal to ", num %even though you got num you change it to num := num - 2

You were a little confused when you said
Ohhh. Then i guess var -= 22 is like saying ' var + var - 22 '?

If so then it makes sense. 

And thank you very much.


-----------------------------------
Clayton
Thu Feb 28, 2008 9:33 pm

RE:Kind of Stupid Question (+=,-=)
-----------------------------------
I very much believe the :+ was a typo.
