Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I add a line break in a string?

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.

like image 262
Jens Schauder Avatar asked Oct 07 '14 12:10

Jens Schauder


People also ask

How do you line break a text?

<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.

How do you force a line break?

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.

How do you add a line break to a string in Python?

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.

What is the symbol for line break?

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 (↵).


1 Answers

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.

like image 117
Sebastian Paaske Tørholm Avatar answered Oct 12 '22 04:10

Sebastian Paaske Tørholm