Here document: Difference between revisions

→‎{{header|Wren}}: Updated to v0.4.0.
m (Add " {{omit from|Delphi}}" because Delphi is based in Pascal and pascal can not handle strings multilines, unless concatenate with "+" char.)
(→‎{{header|Wren}}: Updated to v0.4.0.)
Line 2,238:
 
=={{header|Wren}}==
Wren hasdoes neithernot have heredocs norbut (from v0.4.0) does have raw strings.
 
A raw string is any text delimited by triple quotes, """, and is interpreted literally i.e. any control codes and/or interpolations are not processed as such.
Embedding escape characters in ordinary strings is not too bad in practice as the language doesn't use single quotes or back-ticks at all so these don't need to be escaped. A reasonable workaround is therefore to use a list of strings (one per line) and then join them together with the '\n' newline character.
 
If a triple quote appears on its own line then any trailing whitespace on that line is ignored.
However, if there's a lot of text, it's probably best to just load it in from a file.
 
Borrowing the Ada example (appropriately adjusted) for an illustration of thea formerraw approach:string.
<lang ecmascript>var a = [42
var b = """
"This is a list of 'stringsraw' string with the following properties:",
" - indention is preserved, and",
" - a quotation mark '\"' must be \"escaped\" by preceding it with a '\\'.",
- an escape sequence such as a quotation mark "\\" is interpreted literally, and
"`Have fun!`"
- interpolation such as %(a) is also interpreted literally.
]
"`Have fun!`"
System.print(a.join("\n"))</lang>
"""
System.print(a.join("\n")b)</lang>
 
{{out}}
<pre>
This is a list of 'stringsraw' string with the following properties:
- indention is preserved, and
- an escape sequence such as a quotation mark '"' must be "escaped\\" byis precedinginterpreted itliterally, with a '\'.and
- interpolation such as %(b) is also interpreted literally.
`Have fun!`
</pre>
9,485

edits