Version: v0.5.0 - Beta.  We welcome contributors & feedback.  THanks!

Strings

Strings are sequences of text characters.

They are always surrounded by single quotes.

// ✔ OK
'Hello World!';

// ✖ ERROR: Double-quotes are not valid.
"Hello World!";

// ✖ ERROR: 'Hello' is an unknown command.
Hello World!;

Combining Strings ~

Strings can be appended using the stringy operator ~ (tilde).

let numPaintings = 22;
let firstName = 'Tina';
let lastName = 'Turquoise';

let fullName = firstName ~ ' ' ~ lastName;
//= 'Tina Turquoise'

print(fullName ~ ' has ' ~ numPaintings ~ ' paintings.');
//= 'Tina Turquoise has 22 paintings.'

// Or use the fill() method
let message = '{} has {} paintings.';
print(message.fill(fullName, numPaintings));
//= 'Tina Turquoise has 22 paintings.'

Multi-line Strings '''

Multi-line strings are surrounded with quote fences '''.

The quote fences must appear on separate lines.

Surrounding whitespace and extra indentation will be automatically trimmed, so you can keep the formatting consistent with the surrounding code.

let poem = '''
    Roses are red,
    violets are blue,
    THT has multi-line strings,
    and cows go moo.
''';

Special Characters

For convenience, backticks ` are converted to single-quotes.

'That`s terrific!';
//= 'That's terrific!'

Special characters can be used in strings, using backslash \.

'This is line 1.\nThis is line 2.'
//= This is line 1.
//= This is line 2.

'Green\t#00FF00'  //= 'Green   #00FF00'
'Red\t#FF0000'    //= 'Red     #FF0000'

Escapes

Use a backslash \ to make an escape character appear as-is.

'That\'s terrific!'
//= 'That's terrific!'

'Backslashes (\\) and forward slashes (/)'
//= Backslashes (\) and forward slashes (/)'