Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

Multiple assignments

Assignments can be made to multiple variables in a single assignment statement, for example:

  A,X = B + C;

The value of B + C is assigned to both A and X. In general, it has the same effect as the following statements:

  Temporary = B + C;
  A = Temporary;
  X = Temporary;

The source in the assignment statement must be a scalar or an array of scalars, and if the source is an array, all the targets must also be arrays. If the source is a constant, it is assigned to each of the targets from left to right. If the source is not a constant, it is assigned to a temporary variable, which is then assigned to each of the targets from left to right.

The target can be any reference allowed in a simple assignment.

BY NAME is not allowed in multiple assignments.

Although not recommended, the compound assignment operator may be used in multiple assignments. However, the results may not always be what might be naively expected; for example, the following statements will generally not produce the same results:

  c, c += c;
  c, c = c + c;

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)