Friday, May 20, 2022 20:17

Table of contents >> Introduction > Assignment operators

Assignment operators

This is the simplest operator of them all. It’s expressed simply by the equal (=) sign. Assignment operators are used to assign (give) a value to a variable.

They can also be used in cascade. Lets have a look at simple and cascaded assignment:

One very important thing to always remember is NOT to confuse the assignment operator = with the comparison operator == (a very common programming mistake). If you do, instead of giving a value to a variable, you are comparing that variable to the value, which will have unexpected results and could possibly be very hard to notice and debug.

The concepts explained in this lesson are also shown visually as part of the following video:

Tags: ,

Leave a Reply



Follow the white rabbit