|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
String literalsString literals come in several flavors. Strings start and end with a quotation character, which is either a single quote ('), a double quote ("), or a grave accent (`). No line feeds or quote marks are allowed between these characters unless preceded by a backslash, as shown below. Long strings starts and ends with triple double quotes ("""). Long strings may span several lines and other quotation marks need not to be escaped. Backslash strings starts with backslash (\) followed immediately by symbol. Backslash promotes symbol to string. There may be embedded expressions inside strings.
Identifier string literalIt is also possible to quote an identifier (or a keyword) in a string, in the same manner as keywords can be quoted in identifiers. This is done by adding a backslash (\) in front of the identifier. Implicit string concatentationIf many strings (in any format as described above) are written in succession, they will be concatenated into one string. A limitation is that there cannot be anything between strings except comments and white spaces. Examples:
str = "hello\nworld\n";
str = 'hello\n' `world\n`; // same as above
str = 'hello\n' `world\n`; // same as above
str = \Hello \World; // "HelloWorld"
greeting = """Hello!
Time is now ${anvil.time.getTime()}.
Wuzzup?""";
name = \anvil;
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||