Add support for negative indices for .[]; fix #462

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
This commit is contained in:
William Langford authored and Nicolas Williams committed 2014-07-06 01:40:22 -05:00
1 parent 7d3a44a1e2
commit d0ca11d665
3 files changed
+17 -1

No files matched your search

+9
View File
@@ -256,6 +256,11 @@ sections:
the array), or omitted (in which case it refers to the start
or end of the array).
The `.[2]` syntax can be used to return the element at the
given index. Negative indices are allowed, with -1 referring
to the last element, -2 referring to the next to last element,
and so on.
The `?` "operator" can also be used with the slice operator,
as in `.[10:15]?`, which outputs values where the inputs are
slice-able.
@@ -285,6 +290,10 @@ sections:
input: '["a","b","c","d","e"]'
output: ['["d", "e"]']
- program: '.[-2]'
input: '[1,2,3]'
output: ['2']
- title: "`.[]`"
body: |