The question is in the title.
If I do this in the REPL (SML/NJ in windows commandline)
val x = "hello\nworld";
I'd expect
val x = "hello
world" : string
or something similar, but I get
val x = "hello\nworld" : string
although I found somewhere that \n is a line break in SML strings.
<br>: The Line Break element. The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.
To do a line break in HTML, use the <br> tag. Simply place the tag wherever you want to force a line break. Since an HTML line break is an empty element, there's no closing tag.
In Python, the new line character “\n” is used to create a new line. When inserted in a string all the characters after the character are added to a new line. Essentially the occurrence of the “\n” indicates that the line ends here and the remaining characters would be displayed in a new line.
The glyph for the control character for a hard return is usually a pilcrow (¶), and for the manual line break is usually a carriage return arrow (↵).
When the string is displayed, the line break is displayed as \n
.
However, if you try printing the string, you'll see it as a proper line break:
- val x = "hello\nworld";
> val x = "hello\nworld" : string
- print x;
hello
world> val it = () : unit
It's simply how the string is displayed, and you cannot make the SML interpreter display it as an actual newline except by printing it yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With