Assignments |
Top Previous Next |
The most fundamental statement is the assignment. It specifies that a value is to be stored into a variable. Assignments have the general form:
VARIABLE:= EXPRESSION
An assignment uses a colon-equal symbol (:=) to make a distinction between comparing two values for equality and storing a value into a variable. The ":=" symbol is pronounced "gets". For instance, the statement X:= 5 + 1 is read: "X gets five plus one."
Here are some assignment statements:
Number:= 23; Time:= Time + 1; Pig:= Fish = 0
In the first statement, 23 is stored into the variable named "Number". The second statement adds 1 to whatever is contained in Time and stores the result back into Time. In the last statement, Pig gets the value "true" or "false" depending on whether Fish is a zero. |