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.
Arguments enclosed within brackets are treated as elements within an array.
let array = [ one two 'three four' ]
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]
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 other_array = [ this is the ion ] let array = [ @array @other_array shell ] let as_string = @array echo @array echo $array
hello world this is the ion shell hello world this is the ion shell
::= operators can be used to efficiently concatenate an array in-place.
let array = [1 2 3] let array ++= [5 6 7] let array ::= 0 echo @array
0 1 2 3 5 6 7
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