Computer Science Canada

can someone tell me the use of += and -= operators (SOLVED)

Author:  the_short1 [ Mon Feb 23, 2004 10:57 pm ]
Post subject:  can someone tell me the use of += and -= operators (SOLVED)

ive seen this in some programs but i do not know how/what it does exactly.... ive looked in turing help under operators... and i searched but no luck in finding it...

Author:  Paul [ Mon Feb 23, 2004 11:00 pm ]
Post subject: 

hehe...
+= is the same as something:=something + something else
-= is the same as something:=something - something else
so
code:

number:=number+1
%is the same as%
number+=1

number:=number-1
%is the same as%
number-=1

Author:  the_short1 [ Tue Feb 24, 2004 7:52 am ]
Post subject: 

that was my first guess.... but i wanted to knwo for sure...(also if it has more uses...)

cool... that little things shaves off lots of code...


Thanks,.. (Feeling Like a Noob) Shocked Sad

Author:  naoki [ Tue Feb 24, 2004 5:46 pm ]
Post subject: 

mebbe it's only in C++ but you could also try

*= and
/=
and see if they work as well

Author:  apomb [ Tue Feb 24, 2004 8:09 pm ]
Post subject: 

actually in turing , it works quite well ... i was initially going to reply that even (+=) doesn't work .. but i would have made quite a fool of myself , wouldn't i!? any way ... it works

Author:  jonos [ Tue Feb 24, 2004 9:00 pm ]
Post subject: 

yeah, cervantes uses that a lot and i never understood his code until i understood that. anyways, i wish turing allowed var++ or ++var cause that is SOOOOOO easy. hehe, anyways, everyone go and check out "shadows collide with people" by john frusciante


: