A Copy Is Not a Link
One box can take another box’s value without being tied to it.
In this lesson
- It starts with a question. A program runs three lines: price = 5, then saved = price, then price = 8. What is in saved now?
- The idea you will find. b = a copies the value once. It does not join the boxes. — In the program you traced, b was given a copy of whatever a held at that moment, which was 3. When a later became 10, b knew nothing about it. Each box only changes when a line writes to that box by name. This is why programs keep a copy of a value before changing it.
- How you learn it. By doing: matching, a slider, putting things in order.
- Length. 6 short steps. Progress saves on this phone.
Part of Storing Values: Variables
Storing, changing and reading values — the first thing every program does.