Skip to content

Commit f1752b5

Browse files
committed
DOCS-13966 clarify behavior of zero for $arrayElemAt idx
1 parent 5ea62e1 commit f1752b5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

source/reference/operator/aggregation/arrayElemAt.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,21 @@ Definition
2626
{ $arrayElemAt: [ <array>, <idx> ] }
2727

2828
The ``<array>`` expression can be any valid :ref:`expression
29-
<aggregation-expressions>` as long as it resolves to an array.
29+
<aggregation-expressions>` that resolves to an array.
3030

3131
The ``<idx>`` expression can be any valid :ref:`expression
32-
<aggregation-expressions>` as long as it resolves to an integer.
32+
<aggregation-expressions>` that resolves to an integer:
3333

34-
- If positive, :expression:`$arrayElemAt` returns the element at the
35-
``idx`` position, counting from the start of the array.
34+
- If the ``<idx>`` expression resolves to zero or a positive integer,
35+
:expression:`$arrayElemAt` returns the element at the ``idx``
36+
position, counting from the start of the array.
3637

37-
- If negative, :expression:`$arrayElemAt` returns the element at the
38-
``idx`` position, counting from the end of the array.
38+
- If the ``<idx>`` expression resolves to a negative integer,
39+
:expression:`$arrayElemAt` returns the element at the ``idx``
40+
position, counting from the end of the array.
3941

40-
If the ``idx`` exceeds the array bounds, :expression:`$arrayElemAt`
41-
does not return any result.
42+
If ``idx`` exceeds the array bounds, :expression:`$arrayElemAt` does
43+
not return a result.
4244

4345
For more information on expressions, see
4446
:ref:`aggregation-expressions`.

0 commit comments

Comments
 (0)