# OP=

Buddhi Vikasitha
Greenhorn
Posts: 17

I'm confused with this operational assignment and I need to know how will this one execute and what will the result be? Beginner... thanks.

Stuie Clarky
Ranch Hand
Posts: 98
• 1
+= adds the right variable to the left variable, and stores the result in the left variable, e.g a=1, b=2, a+=b would result in a=3. The * works in a similar fashion, except it multiples instead. In this example you can follow it through in your head and then see if what you get is the same as what the output of 'a' is.

Steve Luke
Bartender
Posts: 4181
22
• 1
Buddhi Vikasitha wrote:I need to know how will this one execute and what will the result be? Beginner... thanks.

Wheras Stuie gave you the basics on how the operators work, your question is a bit more complicated because of the type conversions. The best way to see how it executes and what the result will be would be to run it. What do you get? Then try to break the key line:

into smaller sequential parts to see if you can find out what each step does.

Henry Wong
author
Marshal
Posts: 21192
81
• 1
Steve Luke wrote:
Wheras Stuie gave you the basics on how the operators work, your question is a bit more complicated because of the type conversions. The best way to see how it executes and what the result will be would be to run it. What do you get? Then try to break the key line:

into smaller sequential parts to see if you can find out what each step does.

Also, it may help to know that all compound assignment operators have the same precedence -- and have right to left associativity.

Henry