Assignment

An assignment statement assigns the value of an expression to a simple variable, or to a subscript or slice of a variable. e.g.
    x = a + b
    y[i] = y[i] + 1
    y[i..j] = {1, 2, 3}
The previous value of the variable, or element(s) of the subscripted or sliced variable are discarded. For example, suppose x was a 1000-element sequence that we had initialized with:
    object x
    x = repeat(0, 1000)  -- a sequence of 1000 zeros
and then later we assigned an atom to x with:
    x = 7
This is perfectly legal since x is declared as an object. The previous value of x, namely the 1000-element sequence, would simply disappear. Actually, the space consumed by the 1000-element sequence will be automatically recycled due to phix’s dynamic storage allocation.

Note that the equals symbol '=' is used for both assignment and for equality testing. There is never any confusion because an assignment in phix is a statement only, it cannot be used as an expression (as in C). Alternatively and optionally you can explicitly use ":=" for assignment and "==" for equality testing.