About to!int

bearophile bearophileHUGS at lycos.com
Tue Jan 31 04:49:43 PST 2012


Zardoz:

> Try parse!int(" 12\n");
> http://www.d-programming-language.org/phobos/std_conv.html#parse

It doesn't work, because it accepts a ref string. So you have to write:
string s = " 12\n";
int n = parse!int(s);

But it doesn't work still, it chokes on the first space, so you have to remove it:
string s = "12\n";
int n = parse!int(s);

But it ignores leading noise:
string s = "12x";
int n = parse!int(s);

So it's completely broken for my purposes.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list