String literal

string is zero or more characters written inside single or double quotes.

You can use quotes inside a string, as long as they don't match the quotes surrounding the string:

    var1 = "It's alright"
    var2 = "He is called 'Johnny'"
    var3 = 'He is called "Johnny"'

Single quotes

single quotes allow you to use the syntax of expressions within them.
The @ sign must be placed before the expressions.

    item(title = 'windows dir path: @sys.dir')

Double quotes

double quotes allow you to use the Escape Character inside them only.
The backslash (\) escape character turns special characters into characters.
The sequence \" inserts a double quote in a string:

    var1 = "hello\"world"
    // result: hello"world

The complete set of escape sequences is as follows:

\'Single quote
\"Double quote
\fForm Feed
\nNew Line
\rCarriage Return
\tHorizontal Tab
\vVertical Tab
\uxxxxUnicode escape sequence (UTF-16) \uHHHH (range: 0000 - FFFF)
\xnnnnUnicode escape sequence for character with hex value nnnn (variable length version of \uxxxx)
\UxxxxxxxxUnicode escape sequence (UTF-32) \U00HHHHHH (range: 000000 - 10FFFF)

This page is open source. Noticed a typo? Or something unclear?
Improve this page on GitHub