Does string.isNumeric mean that parse!int will not throw?

Cooler kulkin at hotbox.ru
Thu Feb 20 11:23:28 PST 2014


On Thursday, 20 February 2014 at 19:18:15 UTC, Stanislav Blinov
wrote:
> On Thursday, 20 February 2014 at 19:11:55 UTC, Cooler wrote:
>> The code:
>>
>> string s = "...";
>> if(s.isNumeric){
>>    auto x = parse!int(s); // Can I be sure here that parse will
>> not throw?
>> }
>
> No. s may still contain data that is not convertible to int. For
> example, "nan".

Is there any way to know that a string is convertible to a number
without throwing?


More information about the Digitalmars-d-learn mailing list