@@ -546,7 +546,8 @@ Replace the element at *position* in *anyArray* with *replaceValue*.
546
546
547
547
- ** anyArray** (array): array with elements of arbitrary type
548
548
- ** 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)
550
551
- ** replaceValue** the value to be inserted at * position*
551
552
- ** defaultPaddingValue** to be used for padding if * position* is two or more
552
553
elements beyond the last element in * anyArray*
@@ -599,6 +600,24 @@ RETURN REPLACE_NTH( [ "a", "b", "c" ], 6, "z", "y" )
599
600
{% endaqlexample %}
600
601
{% include aqlexample.html id=examplevar type=type query=query bind=bind result=result %}
601
602
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
+
602
621
## REMOVE_VALUE()
603
622
604
623
` REMOVE_VALUE(anyArray, value, limit) → newArray `
0 commit comments