Problem with std.string.strip(): Can't use result in format routine

Ky-Anh Huynh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 5 05:38:54 PDT 2017


Hi,

I read line from STDIN , and strip them

[code]
auto line_st = line.strip();
[/code]


However, I can't use result in another format routine. Assume my 
input line is "foobar":

[code]
writeln("Stripped line is %s", line_st);
[/code]

This code only prints "Stripped line is ". If I use instead

[code]
writeln("Stripped line is %s", line.strip());
[/code]

the result is "Stripped line is foobar".

What're the difference between the two uses? I'm using `dmd 
v2.075.1`.

Thanks a lot.


More information about the Digitalmars-d-learn mailing list