Array Block
Construct an array from one or more inputs of any type, with options for flattening and merging arrays
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
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
The array created from the inputs.
The indices of the array. I.e. [0, 1, 2, 3, etc]. Useful for zipping with the output array to get the indexes.
The length of the output array.
Editor Settings
If enabled, array inputs will be flattened before joining.
If enabled, array inputs will be flattened recursively.
Example: Creating an Array from Multiple Inputs
- Add an Array Block to your flow.
- Connect three Text blocks with values
"Hello"
,"World"
, and"!"
toInput 1
,Input 2
, andInput 3
of the Array Block respectively.
The Output
of the Array Block will be ["Hello", "World", "!"]
.
Example: Creating an Array from Array Inputs
- Add an Array Block to your flow.
- Connect two Array blocks with values
["One", "Two"]
and["Three", "Four"]
toInput 1
andInput 2
of the Array Block. - Enable the
Flatten
setting.
The Output
of the Array Block will be ["One", "Two", "Three", "Four"]
.
Example: Using the Indices Output
- Add an Array Block with value
["Apple", "Banana", "Cherry"]
. - Add a Text Block with text
"[{{index}}] - {{fruit}}"
. - Connect the
Output
of the Array Block to theFruit
input of the Text Block. - Connect the
Indices
output of the Array Block to theIndex
input of the Text Block. - 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.