apoc.coll.set

Details

Syntax

apoc.coll.set(coll, index, value)

Description

Sets the element at the given index to the new value.

Arguments

Name

Type

Description

coll

LIST<ANY>

The list to be updated.

index

INTEGER

The position of the value in the list to be updated.

value

ANY

The new value to be set.

Returns

LIST<ANY>

Usage examples

The following replaces the item at index 4 with the value 11:

RETURN apoc.coll.set([1,3,5,7,9], 4, 11) AS output;
Results
Output

[1, 3, 5, 7, 11]