write multiple lines without "\n" with writeln

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Nov 20 05:49:55 PST 2014


On Thursday, 20 November 2014 at 11:08:24 UTC, Suliman wrote:
> 	writeln(
> 	"first string"
> 	"second" ~
> 	"string"
> 	);
>
> I expect:
> first string
> second"
> string"

There's no quoted newline there. You could do:

writeln(
"first string
second
string");

with the newlines enclosed in the quotes, then you'd get what you 
want. (There's no extra indenting in my example because the 
indent would show up too when inside quotes)

But if it isn't in the quotes, newlines are basically ignored by 
the compiler like any other whitespace in the code.


More information about the Digitalmars-d-learn mailing list