Jen*_*der 5 string sml line-breaks read-eval-print-loop
问题出在标题中.
如果我在REPL中执行此操作(Windows命令行中的SML/NJ)
val x = "hello\nworld";
Run Code Online (Sandbox Code Playgroud)
我期待
val x = "hello
world" : string
Run Code Online (Sandbox Code Playgroud)
或类似的东西,但我明白了
val x = "hello\nworld" : string
Run Code Online (Sandbox Code Playgroud)
虽然我发现某处\n是SML字符串中的换行符.
显示字符串时,换行符显示为\n.
但是,如果您尝试打印字符串,您会将其视为正确的换行符:
- val x = "hello\nworld";
> val x = "hello\nworld" : string
- print x;
hello
world> val it = () : unit
Run Code Online (Sandbox Code Playgroud)
它只是字符串的显示方式,你不能让SML解释器将它显示为实际换行符,除非自己打印它.
| 归档时间: |
|
| 查看次数: |
10186 次 |
| 最近记录: |