Strings
Strings are of the predefined type string
. Literal strings are set
between double quotes.
Note: See predefined namespace String
Casting
Strings can be used in contexts where a boolean is expected: an empty
string is then interpreted as false
, and true
otherwise.
Concatenating
Strings can be concatenated using the overloaded +
operator, like
so:
Note: See predefined namespace String
Sizing
The length of a string can be obtain by calling the predefined
functions String.length
or String.size
:
Note: See predefined namespace String
Slicing
Substrings can be extracted using the predefined function
String.sub
. The first character has index 0 and the interval of
indices for the substring has inclusive bounds.
The offset and length of the slice are natural number:
Note: See predefined namespace String
Verbatim
Strings can contain control characters, like \n
. Sometimes we need
that each character in a string is interpreted on its own, for example
\n
as two characters instead of a newline character. In that case,
either we escape the backslash character, or we use verbatim
strings. Those have the same type string
as normal (that is,
interpreted) strings.
Verbatim strings are given between backquotes (a.k.a. backticks), instead of double quotes:
Note: See predefined namespace String