且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

多行字符串文字仅在REPL和Worksheet中表现合理

更新时间:2023-10-31 19:05:22

我想这是因为源文件编码.

尝试检查a.toList.lengthb.toList.length.似乎是b == "hello\r\nworld".

多行字符串文字值不取决于平台,而是取决于源文件的编码.实际上,您将获得"""之间的源文件中的所有内容.如果有\r\n,您会在String中找到它.

Multi-line string literal value depends not on the platform, but on the encoding of the source file. Actually you'll get exactly what you have in the source file between """. If there is \r\n you'll get it in your String.