Does array in REGO support the operation like append and extend #77
-
I'd like to know if operation like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @lemonshir! Rego variables and values are immutable, so there's no way to modify them directly. Like most languages with immutable values and vars, you can however use functions that return new values or collections to achieve the same outcome. For your example of appending to an array, you can use the a := [1, 2, 3]
b := [4, 5, 6]
c := array.concat(a, b)
# c == [1, 2, 3, 4, 5, 6] |
Beta Was this translation helpful? Give feedback.
Hi @lemonshir!
Rego variables and values are immutable, so there's no way to modify them directly. Like most languages with immutable values and vars, you can however use functions that return new values or collections to achieve the same outcome. For your example of appending to an array, you can use the
array.concat
built-in: