|Navigation: Language Reference > 11 - Assignments > Assignment Statements >====== Deep Assignment ======
|The label of a GROUP, RECORD, or QUEUE data structure, or an array.
|The label of a GROUP, RECORD, or QUEUE data structure, or a numeric or string constant, variable, procedure, or expression.
The :=: sign executes a deep assignment statement which performs multiple individual component variable assignments from one data structure to another. The assignments are only performed between the variables within each structure that have exactly matching labels, ignoring all prefixes. The compiler looks within nested GROUP structures to find matching labels. Any variable in the destination which does not have a label exactly matching a variable in the source, is not changed.
Deep assignments are performed just as if each matching variable were individually assigned to its matching variable. This means that all normal data conversion rules apply to each matching variable assignment. For example, the label of a nested source GROUP may match a nested destination GROUP or simple variable. In this case, the nested source GROUP is assigned to the destination as a STRING, just as normal GROUP assignment is handled.
The name of a source array may match a destination array. In this case, each element of the source array is assigned to its corresponding element in the destination array. If the source array has more or fewer elements than the destination array, only the matching elements are assigned to the destination.
If the destination is an array variable that is not part of a GROUP, RECORD, or QUEUE, and the source is a constant, variable, or expression, then each element of the destination array is initialized to the value of the source. This is a much more efficient method of initializing an array to a specific value than using a LOOP structure and assigning each element in turn.
The destination or source may also name a CLASS structure, which, in this case, will be treated as a GROUP. However, if you do so, you violate the concept of encapsulation, since deep assignment is a structure piercing operation. Therefore, it is not recommended.
Finally, whenever possible is it always more efficient to use a direct assignment of two matching structures in lieu of deep assignments.
Group1 GROUP S SHORT L LONG END Group2 GROUP L SHORT S REAL T LONG END ArrayField SHORT,DIM(1000) CODE Group2 :=: Group1 !Is equivalent to: !Group2.S = Group1.S !Group2.L = Group1.L !and performs all necessary data conversion ArrayField :=: 7 !Is equivalent to: !LOOP I# = 1 to 1000 ! ArrayField[I#] = 7 !END