Overview

The Array Block is used to construct an array from one or more inputs of any type. It can also be used to merge multiple arrays into a single array using the Flatten setting.

By default, inputs will be flattened, so if any of the inputs are arrays themselves, they will be merged into the output array. This behavior can be disabled by unchecking the Flatten setting.

Inputs

Input [i]
any

An input to create the array from. If an array, will be flattened if the “Flatten” option is enabled. The number of inputs is dynamic based on how many connections there are.

Outputs

Output
any[]

The array created from the inputs.

Indices
number[]

The indices of the array. I.e. [0, 1, 2, 3, etc]. Useful for zipping with the output array to get the indexes.

Length
number

The length of the output array.

Editor Settings

Flatten
boolean
default:true

If enabled, array inputs will be flattened before joining.

Deep
boolean
default:false

If enabled, array inputs will be flattened recursively.

Example: Creating an Array from Multiple Inputs

  1. Add an Array Block to your flow.
  2. Connect three Text blocks with values "Hello", "World", and "!" to Input 1, Input 2, and Input 3 of the Array Block respectively.

The Output of the Array Block will be ["Hello", "World", "!"].

Example: Creating an Array from Array Inputs

  1. Add an Array Block to your flow.
  2. Connect two Array blocks with values ["One", "Two"] and ["Three", "Four"] to Input 1 and Input 2 of the Array Block.
  3. Enable the Flatten setting.

The Output of the Array Block will be ["One", "Two", "Three", "Four"].

Example: Using the Indices Output

  1. Add an Array Block with value ["Apple", "Banana", "Cherry"].
  2. Add a Text Block with text "[{{index}}] - {{fruit}}".
  3. Connect the Output of the Array Block to the Fruit input of the Text Block.
  4. Connect the Indices output of the Array Block to the Index input of the Text Block.
  5. Enable the Split setting on the Text Block.

The Output of the Text Block will be ["[0] - Apple", "[1] - Banana", "[2] - Cherry"].

Flattening Arrays

The Flatten setting treats each element of an array input as a separate element to be added to the main array. The Deep setting recursively flattens all array inputs.

With flatten disabled, you can get arrays of arrays. These are not well supported in Lawme and you may have to use a Code Block to work with them.

Error Handling

If an input is missing or null, the Array Block will simply ignore it during the array creation process.

FAQ

See Also