arrayInsertAt
Description
Returns a new array with an element inserted at the specified position.
- The element type must match the array type.
- Supported element types include
string
,bool
,number
,interval
,timestamp
,regexp
, andenum
.
Syntax
Like many functions in DataPrime, arrayInsertAt
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Arguments
Name | Type | Required | Description |
---|---|---|---|
array | array | true | The array to modify |
position | number | true | The index at which to insert the new element |
value | T | true | The element to insert, must match the array type |
Example
Use case: Insert an item into the middle of a queue
Suppose you have a list of jobs but notice one is missing. Consider the following input:
By inserting 'Job 3'
at position 2
, you restore the intended sequence of jobs.
Output
The result will include the new element at the specified index:
Theme
Light