Workspace 6.21.5
Understanding Object Array Builder

Basic Usage

While an array input is useful when the user knows how many of something to supply to an operation, an ObjectArray is a useful way of passing an unknown number of data objects. The ObjectArrayBuilder operation sits somewhere between these two extremes, allowing the user to create an ObjectArray from a known number of items, or to build up an ObjectArray through successive updates (typically inside some kind of loop).

The ObjectArrayBuilder operation

The ObjectArrayBuilder is a polymorphic operation. Users can change the data type being stored in the object array and they can rename the output of the operation if they wish. The typical usage of an ObjectArrayBuilder is to first set its data type to the data type you want to store, then make connections to the Items to add as necessary. Note that it is possible to store more than one data type in an ObjectArray, so when the data type is changed and items have already been accumulated into the object array, the array will end up with a mix of data types. For most uses, the accumulation should be reset if the data type is changed.

A more complicated example of building up an array inside a loop is shown in example 1.

Example 1: Building up an ObjectArray inside a loop

There are a few key things to note about this example:

  • The object array builder is set to accumulate items. Each iteration of the loop will store one more item. When the loop is reset, the object array builder is also reset, so the array will always hold just one full loop's worth of data at the completion of the loop.
  • The way the Dependencies output of the "Counted loop" and the main output of the "Object array builder" connect to the final "Accumulated object array" is important. The dependency output of "Counted loop" is connected to the dependency input of "Accumulated object array". This means that the loop will get fully executed before anything else. The connection between "Object array builder" and "Accumulated object array" therefore only updates after the loop has executed. This ensures that the object array passed to "Accumulated object array" is fully populated from a complete cycle of the loop.
See also
Polymorphic Operations, CountedLoop