如何在 Ada 中创建一个包含换行符的字符串,其定义也包含这些换行符?
我试过在行尾使用 0..2 个反斜杠,但没有一个可以编译:
usage_info : String := "\
This should be the first line
and both the definition and the output
should contain newlines.";
在 PHP 中这将是:
<<<BLOCK
1
2
3
BLOCK;
const std::string s = "\
1
2
3";
const string s =
@"1
2
3";
最佳答案
据我所知,Ada 和 Java 一样,不支持多行文字。 我唯一看到的是这样的:
usage_info : String := "This should be the first line" & CR & LF
& "and both the definition and the output" & CR & LF
& "should contain newlines.";
当然,您需要with 和使用 Ada.Characters.Latin_1 来使这些常量可见。
关于string - Ada 中的多行字符串文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58517814/