Compile time string manipulation

bearophile bearophileHUGS at lycos.com
Sat Dec 15 04:33:12 PST 2012


js.mdnq:

> static if (std.string.indexOf(S, ")") < -1)
>    ...
> else
>    ...
>
> This always returns false regardless if S contains a 7 or not.

If it doesn't find the substring it returns -1, so that's always 
false. So use:

S.indexOf(")") < 0

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list