Skip to content

Commit 2667a2d

Browse files
committed
DOCS-11969: fix examples in reverseArray
1 parent a1d5c5b commit 2667a2d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

source/reference/operator/aggregation/reverseArray.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,32 @@ If the argument contains subarrays, ``$reverseArray`` only operates on the top l
4343
:header-rows: 1
4444
:widths: 65 35
4545

46-
* - Example
46+
* - Example [#literal]_
4747
- Results
4848

49-
* - ``{ $reverseArray: [ 1, 2, 3 ] }``
49+
* - ``{ $reverseArray: { $literal: [ 1, 2, 3 ] } }``
5050
- ``[ 3, 2, 1 ]``
5151

52-
* - ``{ $reverseArray: { $slice: [ [ "foo", "bar", "baz", "qux" ], 1, 2 ] } }``
52+
* - ``{ $reverseArray: { $slice: [ [ "foo", "bar", "baz", "qux" ], 1, 2 ] } } }``
5353
- ``[ "baz", "bar" ]``
5454

5555
* - ``{ $reverseArray: null }``
5656
- ``null``
5757

58-
* - ``{ $reverseArray: [ ] }``
58+
* - ``{ $reverseArray: { $literal: [ ] } }``
5959
- ``[ ]``
6060

61-
* - ``{ $reverseArray: [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] }``
61+
* - ``{ $reverseArray: { $literal: [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] } }``
6262
- ``[ [ 4, 5, 6 ], [ 1, 2, 3 ] ]``
6363

64+
.. [#literal]
65+
66+
The examples in the table take a literal argument. To avoid parsing
67+
ambiguity if the literal argument is an array, you must wrap the
68+
literal array in a :expression:`$literal` expression or keep the
69+
outer array that designates the argument list (e.g. ``[ [ 1, 2, 3 ]
70+
]`` ) to pass in the literal array ``[1, 2, 3]``.
71+
6472
Example
6573
-------
6674

0 commit comments

Comments
 (0)