Can't detect error with String to number conversions?


Is it right that there's no built-in way to detect if a conversion from a String to a number is actually an error? For example String::getDoubleValue() returning 0.0 from "a36.2" isn't exactly nice. The user probably meant to write "36.2" but typoed the a to the beginning and there isn't a built-in way to detect that I think? (0.0 could of course also be a valid input...)

Could these APIs be changed/extended to something like the following?

double String::getDoubleValue(bool* err=nullptr)

Where if the err is not nullptr it would be set to true if there was an error when parsing the string, false otherwise.


We'll have to discuss this internally, but in the meantime you should take a look at ​String::containsOnly.

Hope this helps!