SplitScript reference / String / parse

String.parse

Method

String.parse<T>() -> T! where T: Numeric

Parses this string as an inferred numeric type.

Parsing consumes the entire string and accepts only ASCII decimal text; surrounding whitespace and digit separators are errors. Integers allow an optional sign and are checked against the exact target width. Floats additionally allow a decimal point and e or E exponent. NaN, inf, and Infinity are accepted case-insensitively. Finite overflow produces signed infinity and underflow produces signed zero.

Effects: allocates

Runtime behavior: available everywhere; synchronous

Examples

Parse a percentage read from process memory

let percentage: f64 = "87.5".parse() else 0.0