String Variables

We can evaluate expressions to assign their result to the variable and print with with $ sigil. Read the chapter expansions for more information about the expansion behavior.

# The CI can not handle deletions properly.
mkdir -p _tmp _tmp/t1 _tmp/t2
cd _tmp
let filelist = *
echo $filelist
cd ..
t1 t2

Slicing a string.

Strings can be sliced in Ion using a range.

let foo = "Hello, World"
echo $foo[..5]
echo $foo[7..]
echo $foo[2..9]
Hello
World
llo, Wo

String concatenation

The ++= and ::= operators can be used to efficiently concatenate a string in-place.

let string = world
echo $string
let string ++= !
echo $string
let string ::= "Hello, "
echo $string
world
world!
Hello, world!