8000 Feature/add array replace nth function (#325) · arangodb/docs@c280a9a · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit c280a9a

Browse files
authored
Feature/add array replace nth function (#325)
1 parent 45042b2 commit c280a9a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

3.7/aql/functions-array.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ Replace the element at *position* in *anyArray* with *replaceValue*.
546546

547547
- **anyArray** (array): array with elements of arbitrary type
548548
- **position** (number): the position of the element to replace. Positions start
549-
at 0. Negative positions are not supported.
549+
at 0. Negative positions are supported, with -1 being the last array element.
550+
If a negative *position* is out of bounds, then it is set to the first element (0)
550551
- **replaceValue** the value to be inserted at *position*
551552
- **defaultPaddingValue** to be used for padding if *position* is two or more
552553
elements beyond the last element in *anyArray*
@@ -599,6 +600,24 @@ RETURN REPLACE_NTH( [ "a", "b", "c" ], 6, "z", "y" )
599600
{% endaqlexample %}
600601
{% include aqlexample.html id=examplevar type=type query=query bind=bind result=result %}
601602

603+
{% aqlexample examplevar="examplevar" type="type" query="query" bind="bind" result="result" %}
604+
@startDocuBlockInline aqlArrayReplaceNth_5
605+
@EXAMPLE_AQL{aqlArrayReplaceNth_5}
606+
RETURN REPLACE_NTH( [ "a", "b", "c" ], -1, "z" )
607+
@END_EXAMPLE_AQL
608+
@endDocuBlock aqlArrayReplaceNth_5
609+
{% endaqlexample %}
610+
{% include aqlexample.html id=examplevar type=type query=query bind=bind result=result %}
611+
612+
{% aqlexample examplevar="examplevar" type="type" query="query" bind="bind" result="result" %}
613+
@startDocuBlockInline aqlArrayReplaceNth_6
614+
@EXAMPLE_AQL{aqlArrayReplaceNth_6}
615+
RETURN REPLACE_NTH( [ "a", "b", "c" ], -9, "z" )
616+
@END_EXAMPLE_AQL
617+
@endDocuBlock aqlArrayReplaceNth_6
618+
{% endaqlexample %}
619+
{% include aqlexample.html id=examplevar type=type query=query bind=bind result=result %}
620+
602621
## REMOVE_VALUE()
603622

604623
`REMOVE_VALUE(anyArray, value, limit) → newArray`

0 commit comments

Comments
 (0)
0