uzl*_*xxx 7 string multiline template-literals raku
在 JavaScript (ES6) 中,您可以使用模板文字 (``) 创建多行字符串,如以下示例所示:
const html = `
<div>
<p>Raku is <b>ofun</b>.</p>
</div>
`
Run Code Online (Sandbox Code Playgroud)
Raku 相当于什么?
Eli*_*sen 11
my constant html = '
<div>
<p>Raku is <b>ofun</b>.</p>
</div>
';
Run Code Online (Sandbox Code Playgroud)
在 Raku 中运行良好。
但是,您可能想使用所谓的heredoc:
my constant html = q:to/HTML/;
<div>
<p>Raku is <b>ofun</b>.</p>
</div>
HTML
Run Code Online (Sandbox Code Playgroud)
省略第一个换行符,但在其他方面完全相同。如果你想插入变量,你可以更改q
为qq
:
my $lang = <Raku Rust Ruby>.pick;
my $html = qq:to/HTML/;
<div>
<p>$lang is <b>ofun</b>.</p>
</div>
HTML
Run Code Online (Sandbox Code Playgroud)
有关引用的更多信息,请参阅引用结构