Skip to content

Commit

Permalink
docs: Add arrays to composite values section
Browse files Browse the repository at this point in the history
Rather simple, but I'm not sure we need more.

Fixes #6727

Signed-off-by: Anders Eknert <anders@eknert.com>
  • Loading branch information
anderseknert authored and ashutosh-narkar committed May 6, 2024
1 parent 1d57280 commit c867c30
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/content/policy-language.md
Expand Up @@ -338,6 +338,24 @@ d := {"a": a, "x": [b, c]}

By defining composite values in terms of variables and references, rules can define abstractions over raw data and other rules.

### Arrays

Arrays are ordered collections of values. Arrays in Rego are zero-indexed, and may contain any value, including
variable references.

```live:eg/arrays:module:merge_down
arr := [1, "two", 3]
```

```live:eg/arrays/lookup:query:merge_down
last := arr[2]
```

```live:eg/arrays/lookup:output:merge_down
```

Use arrays when order matters and duplicate values should be allowed.

### Objects

Objects are unordered key-value collections. In Rego, any value type can be
Expand Down

0 comments on commit c867c30

Please sign in to comment.