Quoting constructs: Difference between revisions

Add Ecstasy example
(Add Ecstasy example)
Line 179:
** Strings <syntaxhighlight lang="bqn">"Hello World"
"Quoted "" String"</syntaxhighlight> any sequence of characters including newlines can be put inside a string. Quotes are escaped by typing two quotes.
 
=={{header|Ecstasy}}==
<syntaxhighlight lang="java">
module test
{
@Inject Console console;
void run()
{
// characters are single quoted
Char ch = 'x';
console.print( $"ch={ch.quoted()}");
 
// strings are double quoted
String greeting = "Hello";
console.print( $"greeting={greeting.quoted()}");
 
// multi-line strings use '|' as a left column
// the start of the first line escapes the '|' to indicate the start of the multiline
// a trailing escape indicates that the current line continues without a linefeed
String lines = \|first line
|second line\
| continued
;
console.print($|lines=
|{lines}
);
 
// in all of the examples above, the $"..." is a template string, containing {expressions}
// the multi-line form uses $|
String name = "Bob";
String msg = $|{greeting} {name},
|Have a nice day!
|{ch}{ch}{ch}
;
console.print($|msg=
|{msg}
);
}
}
</syntaxhighlight>
 
{{out}}
<pre>
ch='x'
greeting="Hello"
lines=
first line
second line continued
msg=
Hello Bob,
Have a nice day!
xxx
</pre>
 
=={{header|FreeBASIC}}==
162

edits