The  syntax in Ion is utilized to denote that the contents within should be parsed as an
array expression. Array variables are also created using the same
let keyword, but
the distinction between a string and an array by additionally requiring that all array arguments
are wrapped within the  syntax. If an array is supplied to
let that is not explicitly
declared as an array, then it will be coerced into a space-separated string. This design decision
was made due to the possibility of an expanded array with one element being interpreted as a
Once created, you may call an array variable in the same manner as a string variable, but you
must use the @ sigil instead of $. When expanded, arrays will be expanded into multiple
arguments, so it is possible to use arrays to set multiple arguments in commands. Do note, however,
that if an array is double quoted, it will be coerced into a string, which is a behavior that
is equivalent to invoking the
NOTE: Brace expansions also create arrays.
Create a new array
Arguments enclosed within brackets are treated as elements within an array.
let array = [ one two 'three four' ]
Indexing into an array
Values can be fetched from an array via their position in the array as the index.
let array = [ 1 2 3 4 5 6 7 8 9 10 ] echo @array echo @array[5..=8]
Copy array into a new array
Passing an array within brackets enables performing a deep copy of that array.
let array_copy = [ @array ]
This will join each element of the array into a string, adding spaces between each element.
let array = [ hello world ] let as_string = @array
::= operators can be used to efficient concatenate an array in-place.
let array = [1 2 3] let array ++= [5 6 7] let array ::= 0
Expand array as arguments to a command
Arrays are useful to pass as arguments to a command. Each element will be expanded as an individual argument, if any arguments exist.
let args = [-l -a --color] ls @args
Dropping Array Variables
drop -a command will drop array variables from the shell.
let array = [one two three] echo @array drop -a array echo @array