RosettaCodeData/Task/Quoting-constructs/Ecstasy/quoting-constructs.ecstasy

35 lines
1.1 KiB
Plaintext

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}
);
// the $"..." is a template string, containing {expressions}
// the multi-line form of the template string uses $|
String name = "Bob";
String msg = $|{greeting} {name},
|Have a nice day!
|{ch}{ch}{ch}
;
console.print($|msg=
|{msg}
);
}
}