[package] [Java implementation] [Execution output]


Assignment


/**
 * Assignment operators
 * <p>
 * In general, assignment operators assign a value derived from
 * the right-hand-side (rhs) of the operator to the location on its left-hand-side (lhs).
 * Assignment operators associate left-to-right, so the result of an assignment
 * may be used as the location of another assignment operation.
 * For example:
 *      x += 1 += 2.
 */

/**
 * Ordinary assignment, using the ":=" operator, is defined so as to require that the
 * location (lhs) and value (rhs) have the same type.
 */
abstract <T> T: (T: location) := (T: value);

/**
 * Arithmetic assignments, using the "+=" and "-=" operators, are defined so that the value (rhs)
 * is not required to be of the same type as the location (lhs). The type of an arithmetic assignment
 * expression is the type of its first argument (which corresponds to the thing that was changed by the assignment).
 * This permits the use of these operators as aliases for the generic "add" and "remove" methods on collections.
 * For example:
 *      listOfInts += 1 += 2 += 3
 */
abstract <T, U> T: (T: location) += (U: value);
abstract <T, U> T: (T: location) -= (U: value);