Shorthand Assignment Operators | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Shorthand Assignment Operators

Somebody please explain a bit more about Shorthand Assignment Operators

10th Nov 2016, 7:35 AM
Nehalarifen
Nehalarifen - avatar
2 Answers
+ 3
short hand operator make things more easier. for ex. if you write..... a = a+5 then this can be written using short hand operator as..... a += 5
10th Nov 2016, 8:16 AM
Harish Nandoliya
Harish Nandoliya - avatar
+ 2
x = x + 1; is the same as x += 1; they both add 1 to the variable x except the second one is the a little faster to write. You don't have to use the shorthand style but just be aware of it so you don't get confused when you find it in someone else's code.
10th Nov 2016, 8:21 AM
J.C Vega
J.C Vega - avatar