Skip to main content

Array

Array typed values are a container for numerically indexed values (referred to as items).

Arrays...

Initialization

Array typed values can be constructed from a literal or templated array.

A templated array is an array which includes one or more variable-reference [string]. At runtime, each reference gets evaluated and replaced with it's corresponding value.

Initialization Example (literal)

- item1
- item2

Initialization Example (templated)

given:

  • someDir/file2.txt is embedded in op
  • someObject
    • is in scope
    • is type coercible to object
    • has property someProperty
- string $(./someDir/file2.txt)
- $(someObject.someProperty)
- [ sub, array, 2]

Item Referencing

Array items can be referenced via $(ARRAY[index]) syntax, where index is the zero based index of the item. If index is negative, indexing will take place from the end of the array.

Item Referencing Example (first item)

given:

  • someArray
    • is in scope
    • is type coercible to array
    • has at least one item
$(someArray[0])

Item Referencing Example (last item)

given:

  • someArray
    • is in scope
    • is type coercible to array
    • has at least one item
$(someArray[-1])

Coercion

Array typed values are coercible to:

  • boolean (arrays which are null or empty coerce to false; all else coerce to true)
  • file (will be serialized to JSON)
  • string (will be serialized to JSON)