Skip Top Navigation Bar

Arithmetic Expressions and the Assignment Operator


The assignment operator (=) happens after the expression is evaluated.

Variables can be mutable (changeable). They can be reassigned new different values. Let's consider another example where a current score for a player gets updated.

  • The value of score starts off with the value of 100.
  • The expression score + 25 is evaluated to 125.
  • This value is assigned to score and now score has the value 125.

As program code gets increasingly more complicated, drawing a diagram to trace the value of the variable can be really helpful.

Resources

Next Learn Tutorial

Learn: Using the Compound Assignment Operator