Skip to content

Commit

Permalink
Merge pull request #1968 from nickanderson/CFE-2929/master
Browse files Browse the repository at this point in the history
CFE-2929 Note that getindices() always returns a list
  • Loading branch information
nickanderson committed Oct 23, 2018
2 parents fe5f61d + 480a6a1 commit 0b06796
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions reference/functions/getindices.markdown
Expand Up @@ -15,15 +15,19 @@ the name of an array or container.
Make sure you specify the correct scope when supplying the name of the
variable.

Note the list which getindices returns is not guaranteed to be in any
specific order.

In the case of a doubly-indexed array (such as `parsestringarrayidx()` and
friends produce), the primary keys are returned; i.e. if
`varref[i][j]` exist for various `i`, `j` and you ask for the keys of
`varref`, you get the `i` values. For each such `i` you can then ask
for `getindices("varref[i]")` to get a list of the `j` values (and so
on, for higher levels of indexing).
**Note:**

- The function **always** returns a list. If called on something that has no
index (for example, an undefined variable) an empty list is returned.

- The list which getindices returns is not guaranteed to be in any specific
order.

- In the case of a doubly-indexed array (such as `parsestringarrayidx()` and
friends produce), the primary keys are returned; i.e. if `varref[i][j]` exist
for various `i`, `j` and you ask for the keys of `varref`, you get the `i`
values. For each such `i` you can then ask for `getindices("varref[i]")` to
get a list of the `j` values (and so on, for higher levels of indexing).

[%CFEngine_function_attributes(varref)%]

Expand Down

0 comments on commit 0b06796

Please sign in to comment.